Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Don't construct placeholder tokenized lines - #12933

Merged
as-cii merged 11 commits into
masterfrom
mb-remove-placeholder-tokenized-lines
Oct 14, 2016
Merged

as-cii merged 11 commits into
masterfrom
mb-remove-placeholder-tokenized-lines

Conversation

@maxbrunsfeld

@maxbrunsfeld maxbrunsfeld commented Oct 11, 2016 •

Copy link
Copy Markdown
Contributor

After merging #11414, we changed how we represent syntactic boundaries to use TokenizedBufferIterator instead. This approach allows us to not build placeholder lines eagerly whenever there is a buffer change or when instantiating a new TokenizedBuffer.

screen shot 2016-10-14 at 15 34 23

In reality, we still need to construct TokenizedLine instances when TokenizedBuffer.prototype.tokenizedLineForRow is called because we want to construct some synthetic null grammar boundaries so that TokenizedBufferIterator doesn't iterate till the end of the buffer (regression), and also because other packages are currently relying on that API. In practice this should be pretty cheap, because in the majority of the cases it happens only for lines that are currently on screen.

@as-cii
as-cii force-pushed the mb-remove-placeholder-tokenized-lines branch 2 times, most recently from 8e8341a to d57b2df Compare October 12, 2016 07:04
maxbrunsfeld and others added 3 commits October 12, 2016 09:04
Previously we were treating the local `NullGrammar` differently from
`atom.grammars.nullGrammar`. These two grammars are conceptually the
same, as the former was created to support editors creation without a
grammar registry.

To keep backwards-compatibility, we also build placeholder lines
on-demand when calling `TokenizedBuffer.prototype.tokenizedLineForRow`.
This ensure that packages relying on the internals of `TokenizedBuffer`
to retrieve syntactic boundaries won't break when the null grammar is
used or large file mode is on.
Since this method will now construct a placeholder line, we want to use
it only where necessary to keep memory footprint to a minimum.
@as-cii
as-cii force-pushed the mb-remove-placeholder-tokenized-lines branch from 53464cb to d3882c1 Compare October 12, 2016 10:09
Antonio Scandurra added 7 commits October 12, 2016 12:10
@as-cii
as-cii force-pushed the mb-remove-placeholder-tokenized-lines branch from 386d808 to 1f210ad Compare October 12, 2016 16:59
@as-cii
as-cii merged commit 69567ed into master Oct 14, 2016
@as-cii
as-cii deleted the mb-remove-placeholder-tokenized-lines branch October 14, 2016 14:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants