zordius/lightncandy — pull request #18 by zordius (2014-03-09 10:23:38+00:00)
Title: Php array access and parent

Another performance boost. Now we do not depend on LCRun2::val() to resolve variable name, we access the input by php array directly!

OLD: LCRun::val(Array('a', 'b', 'c')
NEW: $in['a']['b']['c']

To access parent context we use stored scopes in $cx:

OLD: LCRun::val(Array(2, 'a', 'b', 'c'); // {{../../a.b.c}}
NEW: $cx['scopes'][count($cx['scopes'])-2]['a']['b']['c']

Yes!! Native is the best!

Some results from https://github.com/zordius/HandlebarsTest:

Test 1: **102.77% BOOSTED!!**
NEW: Render 100005 times with lightncandy lib takes 103.97220396996 seconds
{"lib":"lightncandy","test":"fixture\/019-hb-eachparent-001.json","loop":"100005","time":103.97220396996,"match":"YES","diff":null}
OLD: Render 100005 times with lightncandy lib takes 210.82518315315 seconds
{"lib":"lightncandy","test":"fixture\/019-hb-eachparent-001.json","loop":"100005","time":210.82518315315,"match":"YES","diff":null}

Test 2: **61.83% BOOSTED!!**
NEW: Render 1005 times with lightncandy lib takes 49.346987009048 seconds
{"lib":"lightncandy","test":"fixture\/livetest-001-hb-001.json","loop":"1005","time":49.346987009048,"match":"YES","diff":null}
OLD: Render 1005 times with lightncandy lib takes 79.857676029205 seconds
{"lib":"lightncandy","test":"fixture\/livetest-001-hb-001.json","loop":"1005","time":79.857676029205,"match":"YES","diff":null}

Test 3: **101.78% BOOSTED!!**
NEW: Render 10005 times with lightncandy lib takes 24.311310052872 seconds
{"lib":"lightncandy","test":"fixture\/021-hb-manyparent-003.json","loop":"10005","time":24.311310052872,"match":"YES","diff":null}
OLD: Render 10005 times with lightncandy lib takes 49.055814981461 seconds
{"lib":"lightncandy","test":"fixture\/021-hb-manyparent-003.json","loop":"10005","time":49.055814981461,"match":"YES","diff":null}

References: #11