-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a simplified codepath if no bidi isolation controls are present. #131
Conversation
If there aren't any bidi isolation control characters in the paragraph, each level run directly corresponds to one isolating run sequence. In this case we can take a simplified codepath to process them.
We can easily accumulate the level runs as part of the initial explicit::compute() pass over the text; this avoids the need for a separate pass over the levels array at the beginning of prepare::isolating_run_sequences to collect them.
src/prepare.rs
Outdated
@@ -97,7 +101,7 @@ pub fn isolating_run_sequences( | |||
}; | |||
|
|||
isolating_run_sequences.push(IsolatingRunSequence { | |||
runs: vec![run], | |||
runs: vec![run.clone()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use .drain()
or into_iter
so we can move instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we can just remove the .clone()
, it's not needed here.
@@ -182,6 +190,22 @@ pub fn compute<'a, T: TextSource<'a> + ?Sized>( | |||
levels[i + j] = levels[i]; | |||
processing_classes[i + j] = processing_classes[i]; | |||
} | |||
|
|||
// Check if we need to start a new level run. | |||
if i == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're moving level_runs
logic here then we should:
- link to the spec
- mention in the fn docs that this code also handles that part of the spec
- ideally, more comments referencing spec list items or other text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added/tidied up comments, as well as added a test for the edge-case of calling the paragraph API with empty text (and RTL direction, which prevents us taking the early exit in compute_bidi_info_for_para
).
… changes from servo/unicode-bidi#131. r=platform-i18n-reviewers,supply-chain-reviewers,gregtatum No change in behavior, just internal performance optimizations. Differential Revision: https://phabricator.services.mozilla.com/D203729
… changes from servo/unicode-bidi#131. r=platform-i18n-reviewers,supply-chain-reviewers,gregtatum No change in behavior, just internal performance optimizations. Differential Revision: https://phabricator.services.mozilla.com/D203729
If there aren't any bidi isolation control characters in the paragraph, each level run directly corresponds to one isolating run sequence. (See notes under https://www.unicode.org/reports/tr9/#BD13.) In this case we can take a simplified codepath to process them.
Also, we can avoid the need for a separate pass over the levels array to find level runs by collecting the level runs at the same time as the levels array is being set up, during explicit::compute().