This adds an NthCache which will cache the ordinal position of elements. Only
nodes which have >= 32 sibblings are cached - the cache has performance/memory
overhead and for smaller nodes, walking is cheaper.
Using the new benchmark: https://github.com/lightpanda-io/demo/pull/245 under
particularly bad conditions (W=4000):
main:
case match iters us/query
:nth-child(2n) 2000 2 55862.5
:nth-of-type(2n) 1999 2 57675.0
:nth-last-of-type(2n) 1999 2 53935.0
ancestor :nth-child(2n) 4000 1 111855.0
list of two nth 2667 1 111180.0
PR:
case match iters us/query
:nth-child(2n) 2000 258 388.1
:nth-of-type(2n) 1999 245 409.6
:nth-last-of-type(2n) 1999 245 409.0
ancestor :nth-child(2n) 4000 168 596.1
list of two nth 2667 160 626.8
Firefox
case match iters us/query
:nth-child(2n) 2000 460 217.4
:nth-of-type(2n) 1999 445 224.7
:nth-last-of-type(2n) 1999 260 384.6
ancestor :nth-child(2n) 4000 246 406.5
list of two nth 2667 294 340.1
With no regressions in the other cases.