JSON pull parsing API isn't as efficient as it should be #719
Labels
accepting contributions
Issues that are suitable to be worked on by anybody, not just maintainers
std
Changes related to the standard library
Commit 0e34cc3 adds support for parsing JSON documents without the need to allocate intermediate
Json
values. Unfortunately this API exposes a new problem: Inko's lack of uninitialized/partially initialized memory means you have to allocate some sort of dummy value, then update that in-place or overwrite it with the parsed data. In other words, you end up with something like this:Here the initial
Location
is redundant, givenrequire_all
requires a value to be parsed from the input stream.Since closures capture by value (such that they can outlive their stack frames), you can't use a bunch of local variables of type
Option[Whatever]
either, as the assignment isn't visible outside the closure. Even if it was, you're still creating a bunch ofOption
values followed by a redundant "is it in fact aSome
and not aNone
?" check after therequire_all
.We'll need something better that doesn't suffer from these issues.
The text was updated successfully, but these errors were encountered: