Repository navigation
⚡ perf: optimize string traversal in FastHash.fnv1a - #28
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Use index-based loop with codeUnitAt(i) instead of iterating over codeUnits to eliminate iterator allocation during string hashing. Co-authored-by: esenmx <43244505+esenmx@users.noreply.github.com>
Existing tests only assert determinism and inequality, so a traversal change that alters output would pass. Pin 'a' and 'hello' from the released algorithm, split into 32-bit halves to stay dart2js-compilable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
b685253 to
d3d27a5
Compare
Restore the indexed codeUnitAt loop in FastHash.fnv1a (literal revert of #21, byte-identical to the form shipped in v4.0.0 and documented in its CHANGELOG). Hash output is unchanged; on AOT the for-in over s.codeUnits paid a fixed ~2ns/hash ListIterator setup plus a per-step length check, ~20-30% on short keys, parity on JIT. No CHANGELOG entry: 4.0.0 already documents the indexed form. Review changes: add an in-source rationale comment above the loop so the #12/#21/#28 ping-pong stops. Review changes: add known-answer vectors for 'a' and 'hello' (split 32-bit literals, inside the JS-skipped group) so output-changing loop edits are caught. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
⚡ [perf: optimize string traversal in FastHash.fnv1a]
for (final codeUnit in s.codeUnits)withfor (var i = 0; i < s.length; i++)ands.codeUnitAt(i)inFastHash.fnv1a.s.codeUnitsallocates anIterable/ iterator object and incurs function call overhead for iterator navigation. UsingcodeUnitAt(i)in an indexed loop avoids iterator allocations and reduces execution time during string hash calculations.PR created automatically by Jules for task 7446082957158051632 started by @esenmx