hummingbird icon indicating copy to clipboard operation
hummingbird copied to clipboard

Optimise FlatDictionary init for scenarios where no values are stored and llow inlining access

Open Joannis opened this issue 1 year ago • 3 comments

This provides specialized access to the type, and virtually eliminates its presence from routes where a flat dictionary is not used. This affects the route parameters primarily, but helps in particular because CoreRequestContext always starts out with an empty Parameters instance.

Joannis avatar May 19 '24 20:05 Joannis

Empty arrays don't allocate any memory, so I'm not sure this is going to be a saving, as you have added a branch whenever accessing the parameters now

adam-fowler avatar May 20 '24 06:05 adam-fowler

I think my measurements are macOS-specific then. Swift arrays do seem to have a different (default) implementation from the ContiguousArray one

Joannis avatar May 20 '24 18:05 Joannis

@Joannis can I close this?

adam-fowler avatar Oct 06 '25 06:10 adam-fowler