43081j / picoquery

A small library for parsing and serializing query strings
MIT License
69 stars 2 forks source link

perf: follow nested object during parsing #23

Closed PondWader closed 2 months ago

PondWader commented 2 months ago

The current version of picoquery tracks the key path in an array and then processes the key path afterwards. This is bad for performance for two reasons. Firstly pushing to an array is more expensive than just setting a string value and secondly it means the path needs to be processed twice when parsing nested query strings.

This can be improved by tracking the current object whilst parsing. The previous and current key must be tracked in order to know whether to create an array or an object in place of the previous key.

image