Skip to content

Commit

Permalink
Use SmallVec for the stack in explicit::compute().
Browse files Browse the repository at this point in the history
  • Loading branch information
jfkthame committed Feb 27, 2024
1 parent 5a620a6 commit d3df915
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/explicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
//!
//! <http://www.unicode.org/reports/tr9/#Explicit_Levels_and_Directions>

#[cfg(feature = "smallvec")]
use smallvec::{SmallVec, smallvec};

use super::char_data::{
is_rtl,
BidiClass::{self, *},
Expand All @@ -33,6 +36,12 @@ pub fn compute<'a, T: TextSource<'a> + ?Sized>(
assert_eq!(text.len(), original_classes.len());

// <http://www.unicode.org/reports/tr9/#X1>
#[cfg(feature = "smallvec")]
let mut stack: SmallVec::<[Status; 8]> = smallvec![Status {
level: para_level,
status: OverrideStatus::Neutral,
}];
#[cfg(not(feature = "smallvec"))]
let mut stack = vec![Status {
level: para_level,
status: OverrideStatus::Neutral,
Expand Down

0 comments on commit d3df915

Please sign in to comment.