I spent most of today desperately trying to optimize a section of code that I wrote.
Among other things, I'm writing a version of malloc for Gravity Pipe. For those of you who haven't had the terrific fun of writing in C, malloc is a function that lets you set aside a certain number of bits so that you can use them later. The computer knows not to touch them (since you already set them aside) which means that another program won't accidentally write over stuff you were trying to save. How will this be worked into gameplay and combat? Wait and see.
As it turns out, this is actually pretty difficult to write if you want it to work reasonably fast. There are a number of relatively easy ways to get something like this to work, but each one will contain a step--whether it's searching for open areas, writing to those open areas, or deleting the malloc'd space once you're done--which will be very slow.
After a day of working it out, I think I've come up with a decently fast solution which involves a a heap, a second heap which keeps the first heap from growing too large, and hash table.
That's all for today. I need to debug my heap implementation.