Chris Allen ☦︎ 希腊天主教 ☦️🇻🇦
banner
chris.bitemy.app
Chris Allen ☦︎ 希腊天主教 ☦️🇻🇦
@chris.bitemy.app
程序员 | 一千个敌人的王子 | 拜占庭 米塞斯 党团 | Πρίγκιπας με μυριάδες εχθρούς
Is Clarkhat Best Hat?

Y/N: Y
June 19, 2025 at 6:45 AM
Reposted by Chris Allen ☦︎ 希腊天主教 ☦️🇻🇦
nnCompatTrampoline is a beautiful name for a shared library
June 5, 2025 at 9:30 AM
yeah that doesn't make any sense to me. I'm probably missing something here.
December 28, 2024 at 2:48 PM
For enums (sum types) what you want is called a prism, for structs (product types) it's a lens. There's a lot of options here, just depends on how much type-safety/convenience you want.
December 25, 2024 at 7:30 PM
Here are some options I found:

- docs.rs/serde_json/l...
- use the existing API and ? away the fallible parts between .as_object etc. calls
- docs.rs/json-patch/l...
- docs.rs/smart_access... is the freshest lens alternative I can find. May need to add serde_json integration.
Value in serde_json::value - Rust
Represents any valid JSON value.
docs.rs
December 25, 2024 at 7:30 PM
The thing lens would make easier is it's designed to enable setters in addition to getters. I can't see anything about "setters" in serde_json_path so that might be the gotcha.
December 25, 2024 at 7:21 PM
You could try using something like lens for this but it isn't likely to be easier than serde_json_path.
December 25, 2024 at 7:20 PM
You can still ask for the borrow checker's assistance in unsafe code in some instances as well. I agree with you, It's a lot better than writing C.
December 12, 2024 at 5:25 PM
I also didn't feel like I had a very chunky test input for the benchmark and I feel like I could've done more on the file input & parsing side. I wanted to avoid the redundant iteration of the .lines() for width & height.
December 12, 2024 at 4:53 PM
After I applied the optimizations they were both at 155 microseconds, but the recursive one is maybe at risk of blowing the stack on a larger problem input. I could've taken it further but ran out of gas/time. Would've entailed getting rid of all the hashmaps, etc.
December 12, 2024 at 4:51 PM
iterative version was spilling registers more between loop iterations in the assembly as well
December 12, 2024 at 4:46 PM
memory access in the recursive version might've been more linear and localized, iterative was more scattershot initially. row major vs. column major impacts this.
December 12, 2024 at 4:45 PM
The iterative version was eating it harder on the Vec reallocation initially I think. It seemed like it had more calls out to the hashing stuff as well but I'm not confident in that.

Pre-allocating the data structures made the biggest diff but I got iterative from 280 -> 155 micros on 12900K.
December 12, 2024 at 4:43 PM
changing point's field type to i32 instead of isize improved both down to around 150-160 microseconds
December 11, 2024 at 5:43 AM
row-major indexing in iterative's get_unchecked improved it 3.7%, neck-in-neck now.
December 11, 2024 at 5:39 AM