Wednesday, October 7, 2009

Increasing the code weight, just slightly

There's an old computer joke, which was wonderfully executed in a Dilbert strip some years ago.

Three engineers are reminiscing about the good old days:
  • The first says "in my day, we had to write everything in assembly language"
  • The second says "in my day, we had to write everything in 1's and 0's"
  • The third says "you had 1's? all we had were 0's!"
This joke came to mind last night when I finally cracked a little puzzle that had been bugging me for many weeks, and submitted the following fix:


65c65
< private BaseCache tCache = new BaseCache();
---
> private BaseCache tCache = new BaseCache(0);
(The point of the fix is that the integer argument to the BaseCache constructor specifies the cache size; the default is 500, and 0 means "unlimited". For this particular instance of this particular cache, we wish the cache to be unlimited.)

I was a bit worried about the effect on the code size, but since a 0 is considerably lighter than a 1, I'm feeling fairly sanguine.

No comments:

Post a Comment