Commit Graph

1 Commits

Author SHA1 Message Date
57ed9d261e Day 7 optimization
Okay, this optimization was easier than I thought it'd be.

I started by not building a new list every time I wanted to operate on the next value since that seemed like low-hanging fruit. That helped, but not as much as I expected (as is always the case with optimization, I feel).

Next I ran this under a profiler and it showed that string concatenation was the biggest offender, so I found a way to do that without involving strings (it's a bit convoluted, but optimizations tend to do that...) and that cleaned up most of the problem.

After that, getting the next element from the list was a (very minor) next-highest offender, so I cached that locally.

Finally, on a whim I decided that the tuple wasn't helping me anymore, so I removed it and was surprised to see another 100ms or so disappear. I guess constructing those is worse than I thought...gotta file that away for later. I'm a little surprised that it didn't show up in the profiler (or I didn't know how to read it, perhaps).
2024-12-07 10:50:59 -06:00