luwes / js-diff-benchmark

Simple benchmark for testing your DOM diffing algorithm.
66 stars 5 forks source link

Add tail-skip #37

Closed dy closed 4 years ago

dy commented 4 years ago

With considerations from #35 by @WebReflection (safe array access), also with added tail-skip. It bumps from 208 → 251 bytes, but makes prepend faster and safer array deoptimization.

WebReflection commented 4 years ago

wouldn't this:

while (--n >= dif && b[n] == a[n - dif]) end = b[n]

be smaller as such? 🤔

while (n-- > dif && b[n] == a[n - dif]) end = b[n]
dy commented 4 years ago

@WebReflection replaced dif with n/m for aLength/bLength from your example - it still had risk of a overshoot on initial check. Also a bit less cryptic.

WebReflection commented 4 years ago

this looks good to me, not sure you need to adjust anything else, but feel free to merge 👋