From 59b058a3c8b9e5387381574da6bbc05af437527c Mon Sep 17 00:00:00 2001 From: mac Date: Sun, 1 Nov 2026 15:38:52 +0800 Subject: [PATCH] perf: keep ASCII LUT parsing fast alongside Unicode decoding --- verification/LUTEncoding.json | 27 ++++++++++++++++++++++++--- 大鱼调色/Plugin/DYLUTLibrary.mm | 6 +++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/verification/LUTEncoding.json b/verification/LUTEncoding.json index c00a973..c5468f3 100644 --- a/verification/LUTEncoding.json +++ b/verification/LUTEncoding.json @@ -20,7 +20,7 @@ "encoding": { "pass": true, "checks": 179, - "mainHeartbeatMaxGapMS": 6.282333517447114, + "mainHeartbeatMaxGapMS": 6.283249938860536, "scope": "Synthetic isolated UTF-8/16/32 LE/BE BOM/no-BOM, line endings, Unicode spacing, exact colors, corruption, async import and cancellation. No user files modified.", "results": [ { @@ -742,7 +742,7 @@ ], "largeEncodedBytes": 54925360, "encodedImportFiles": 40, - "mainHeartbeatTicks": 234 + "mainHeartbeatTicks": 166 }, "library": { "checks": 112, @@ -1039,5 +1039,26 @@ "limitations": [ "No claim of support for every historical charset or a non-Cube/binary LUT format.", "Live FCP acceptance and final installed GPU checks remain pending." - ] + ], + "browser": { + "sourceBytes": 197731344, + "mainHeartbeatMaxGapMS": 6.267083343118429, + "bulkFiles": 24, + "initialLiveThumbnailViews": 45, + "snapshotsReadDuringImport": 1512, + "mainHeartbeatTicks": 1512, + "scope": "Synthetic 24 x 65-cube import with real main-run-loop heartbeat and snapshot reads; headless browser cancellation, latest selection and 3,025-entry virtualization. No user library or visible test app.", + "pass": true, + "largeCatalogEntries": 3025, + "cubeDimension": 65, + "initialLiveFolderViews": 15, + "importSeconds": 7.526092541636899, + "checks": 67 + }, + "discardedPreOptimizationSubmission": { + "id": "f9bfc2f2-e69d-4589-ae93-e9ce943ea44f", + "compiledSource": "8951725be233eff73627464fd78315b358d8fae4", + "installed": false, + "reason": "Replaced before installation by an optimized ASCII whitespace fast path. The next submission contains changed code, not a duplicate upload of the same artifact." + } } diff --git a/大鱼调色/Plugin/DYLUTLibrary.mm b/大鱼调色/Plugin/DYLUTLibrary.mm index 8430848..6b4a28c 100644 --- a/大鱼调色/Plugin/DYLUTLibrary.mm +++ b/大鱼调色/Plugin/DYLUTLibrary.mm @@ -140,9 +140,9 @@ static BOOL DYLUTText(NSData *bytes,std::string& text,NSProgress *progress,NSErr static std::string_view DYLUTTrim(std::string_view v) { while(!v.empty()) { unsigned char c=v.front();size_t count=0; - if(c==' '||(c>=9&&c<=13))count=1; - else if(v.size()>=2&&v.substr(0,2)=="\xc2\xa0")count=2; - else if(v.size()>=3&&(v.substr(0,3)=="\xe1\x9a\x80"||v.substr(0,3)=="\xe2\x80\xaf"||v.substr(0,3)=="\xe2\x81\x9f"||v.substr(0,3)=="\xe3\x80\x80"||(v.substr(0,2)=="\xe2\x80"&&(unsigned char)v[2]>=0x80&&(unsigned char)v[2]<=0x8a)))count=3; + if(c<0x80){if(c==' '||(c>=9&&c<=13))count=1;else break;} + else if(c==0xc2&&v.size()>=2&&v[1]=='\xa0')count=2; + else if((c==0xe1||c==0xe2||c==0xe3)&&v.size()>=3&&(v.substr(0,3)=="\xe1\x9a\x80"||v.substr(0,3)=="\xe2\x80\xaf"||v.substr(0,3)=="\xe2\x81\x9f"||v.substr(0,3)=="\xe3\x80\x80"||(v.substr(0,2)=="\xe2\x80"&&(unsigned char)v[2]>=0x80&&(unsigned char)v[2]<=0x8a)))count=3; if(!count)break;v.remove_prefix(count); }return v; }