Skip to content

Commit

Permalink
Use faster string length
Browse files Browse the repository at this point in the history
Summary: Avoid using chars, use the fast string length instead.

Reviewed By: lmvasquezg

Differential Revision: D54631255

fbshipit-source-id: 1a803905d223617a169f433bc49c9003486de6b5
  • Loading branch information
ndmitchell authored and facebook-github-bot committed Mar 7, 2024
1 parent f0c1fa1 commit a16cc26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions starlark_syntax/src/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ use allocative::Allocative;
use dupe::Dupe;
use once_cell::sync::Lazy;

use crate::fast_string;

/// A small, `Copy`, value representing a position in a `CodeMap`'s file.
#[derive(
Copy, Clone, Dupe, Hash, Eq, PartialEq, PartialOrd, Ord, Debug, Default, Allocative
Expand Down Expand Up @@ -349,9 +351,7 @@ impl CodeMap {
let line = self.find_line(pos);
let line_span = self.line_span(line);
let byte_col = pos.0 - line_span.begin.0;
let column = self.source_span(line_span)[..byte_col as usize]
.chars()
.count();
let column = fast_string::len(&self.source_span(line_span)[..byte_col as usize]).0;

ResolvedPos { line, column }
}
Expand Down

0 comments on commit a16cc26

Please sign in to comment.