usecanvas / canvas-native-3

https://usecanvas.github.io/canvas-native-3
4 stars 1 forks source link

Use full name or remove starting delimiter #6

Closed soffes closed 8 years ago

soffes commented 8 years ago

Since we have a two letter name, delimiter, and then metadata, we can either use the full name or remove the starting delimiter:

pg{}|Hello

or

paragraph|{}|Hello

Since we know the key will be 2 characters, having the starting delimiter is not necessary.

jclem commented 8 years ago

@soffes I like the delimiter between each component so that we can use String#split, which is significantly faster than String#match:

https://gist.github.com/jclem/e85a026c6d9dde57ba273f3a12d95123

screenshot 2016-04-12 15 25 56

I realize we could slice(2), then split(SEPARATOR), but I'd rather be able to just split(SEPARATOR). Doing slice(2); split(SEPARATOR) is also significantly slower than both String#match and String#split. Obviously, these benchmarks for for JavaScript, but I'd be surprised if they differed much in other runtimes, as far as perf ranking is concerned.