Share prefix pattern data in execpolicy2 instead of cloning

This commit is contained in:
kevin zhao
2025-11-12 16:51:18 -05:00
parent 0f51ed0baa
commit 7b5916cb4b
2 changed files with 14 additions and 10 deletions

View File

@@ -12,6 +12,7 @@ use starlark::values::Value;
use starlark::values::list::ListRef;
use starlark::values::list::UnpackList;
use starlark::values::none::NoneType;
use std::sync::Arc;
use crate::decision::Decision;
use crate::error::Error;
@@ -209,11 +210,13 @@ fn policy_builtins(builder: &mut GlobalsBuilder) {
.split_first()
.ok_or_else(|| Error::InvalidPattern("pattern cannot be empty".to_string()))?;
let rest: Arc<[PatternToken]> = remaining_tokens.to_vec().into();
for head in first_token.alternatives() {
let rule = Rule::Prefix(PrefixRule {
pattern: PrefixPattern {
first: head,
rest: remaining_tokens.to_vec(),
first: Arc::from(head.as_str()),
rest: rest.clone(),
},
decision,
});