mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-06 17:12:07 +08:00
refactor(enhance): lowercase takes a reference and chain support is copy
use_lowercase borrows the mapping and clones only the values; call sites no longer clone whole configs. ChainSupport is a fieldless enum and now Copy; builtin() registers each support pair without clones.
This commit is contained in:
@@ -22,10 +22,10 @@ type EvalOutcome = (Result<Mapping, std::string::String>, Vec<(String, String)>)
|
||||
pub(super) async fn use_script(script: String, config: Mapping, name: String) -> ScriptResult {
|
||||
// The template is identity-plus-lowercasing; skip the Boa round-trip.
|
||||
if script == tmpl::ITEM_SCRIPT {
|
||||
return (use_lowercase(config), vec![], vec![]);
|
||||
return (use_lowercase(&config), vec![], vec![]);
|
||||
}
|
||||
|
||||
let json = match serde_json::to_string(&use_lowercase(config.clone())) {
|
||||
let json = match serde_json::to_string(&use_lowercase(&config)) {
|
||||
Ok(json) if json.len() <= MAX_JSON_SIZE => json,
|
||||
Ok(_) => {
|
||||
let message = "Configuration size exceeds maximum allowed size";
|
||||
@@ -173,7 +173,7 @@ fn eval_script(script: &str, config_json: &str, name: &String) -> EvalOutcome {
|
||||
}
|
||||
|
||||
match parse_json_safely(&result) {
|
||||
Ok(config) => (Ok(use_lowercase(config)), outputs.lock().to_vec()),
|
||||
Ok(config) => (Ok(use_lowercase(&config)), outputs.lock().to_vec()),
|
||||
Err(err) => {
|
||||
logging!(
|
||||
error,
|
||||
|
||||
Reference in New Issue
Block a user