Skip to content

Commit fbf530d

Browse files
Jeremy Braunfacebook-github-bot
Jeremy Braun
authored andcommitted
Fix query string parsing time regression
Summary: D71483524 Introduced an inadvertent N^2 search for target_literal strings in the query string to save memory. We're guaranteed the `l` literal here is a substring of the main query string, and can use that to compute the offset/len directly with pointer arithmatic, and save the searches. Reviewed By: JakobDegen Differential Revision: D72821365 fbshipit-source-id: 62822444dddb1f2eda82bb943569a9fd151d2265
1 parent 4de5f06 commit fbf530d

File tree

2 files changed

+4
-2
lines changed
  • app/buck2_interpreter_for_build/src

2 files changed

+4
-2
lines changed

app/buck2_interpreter_for_build/src/attrs/coerce/attr_type/query.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ impl QueryAttrTypeExt for QueryAttrType {
7777
.into_iter()
7878
.map(|(l, p)| {
7979
query
80-
.find(l)
81-
.map(|offset| ((offset, l.len()), p))
80+
.as_str()
81+
.substr_range(l)
82+
.map(|range| ((range.start, range.len()), p))
8283
.internal_error("Not found in query")
8384
})
8485
.try_collect()?,

app/buck2_interpreter_for_build/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(error_generic_member_access)]
1111
#![feature(try_blocks)]
1212
#![feature(iterator_try_collect)]
13+
#![feature(substr_range)]
1314

1415
use std::sync::Once;
1516

0 commit comments

Comments
 (0)