Hacker News new | ask | show | jobs
by evmar 760 days ago
The "maybe you don't need a linked list" proposal at the bottom seems significantly better than the options presented in the post:

- almost no cost in the non-erroring path

- no extra data structures to manage

- a lot less code

I think the post would benefit from a better analysis of why this doesn't work for them.

2 comments

Indeed, I agree with your points.

This idea was added after I wrote the post and wasn't taken from my own optimization efforts in `jsonschema`. Originally, in `jsonschema` the output type is actually a badly composed iterator and I intended to simplify it to just a `Result<(), ValidationError>` for the article, but with this output, there are actually way better optimizations than I originally implemented.

If I'd discovered this idea earlier, I'd probably spend more time investigating it.

Indeed, also building a linked list over the stack like that is a crafty but very weird design. Keep it simple.