Skip to content

Commit a16cc26

Browse files
ndmitchellfacebook-github-bot
authored andcommitted
Use faster string length
Summary: Avoid using chars, use the fast string length instead. Reviewed By: lmvasquezg Differential Revision: D54631255 fbshipit-source-id: 1a803905d223617a169f433bc49c9003486de6b5
1 parent f0c1fa1 commit a16cc26

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

starlark_syntax/src/codemap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ use allocative::Allocative;
3838
use dupe::Dupe;
3939
use once_cell::sync::Lazy;
4040

41+
use crate::fast_string;
42+
4143
/// A small, `Copy`, value representing a position in a `CodeMap`'s file.
4244
#[derive(
4345
Copy, Clone, Dupe, Hash, Eq, PartialEq, PartialOrd, Ord, Debug, Default, Allocative
@@ -349,9 +351,7 @@ impl CodeMap {
349351
let line = self.find_line(pos);
350352
let line_span = self.line_span(line);
351353
let byte_col = pos.0 - line_span.begin.0;
352-
let column = self.source_span(line_span)[..byte_col as usize]
353-
.chars()
354-
.count();
354+
let column = fast_string::len(&self.source_span(line_span)[..byte_col as usize]).0;
355355

356356
ResolvedPos { line, column }
357357
}

0 commit comments

Comments
 (0)