amazon-ion / ion-element-kotlin

IonElement is an immutable in-memory representation of the Ion data format. IonElement's API is idiomatic to Kotlin.
Apache License 2.0
8 stars 8 forks source link

Investigate the possibility of caching IonElement instances #87

Open popematt opened 5 months ago

popematt commented 5 months ago

If someone is reading data with a lot of repeated values, we might be able to avoid allocating many duplicate objects if we can maintain a cache of frequently used values.

This is likely a very difficult problem for Ion 1.0. However, using Ion 1.1 we could create caches for particular macro invocations. It would be especially beneficial for macros that accept few arguments and produce a large result.

If the user is loading their data with any metas information, caching is probably infeasible because even if we encounter the same value, its metadata (e.g. location) could be different.