“NOTE: This is not called YET. It’s just a placeholder for future changes.”

In my quest to rid Firefox of code that doesn’t do anything it is possible to screw up and delete a method that is only used by outside code. So far, I’ve hit a component that isn’t used in Firefox, methods that aren’t used in Firefox and methods that claim someone is about to use them (with a timestamp from 8 years ago). That and I discovered some code only appears to be used from BeOS or OS/2 specific ifdefs.

Not surprisingly, I had someone comment that I do some “dangerous shit”. Sure, I can see why someone would think that.

My protection: I use the try server to make sure that everything builds on supported platforms. On top of that every patch gets reviewed.

Furthermore, I would like to point out that methods that aren’t called within Firefox are less likely to be tested and correct. So if one leaves code that should only be called from other projects, it’d be appropriate if we had some unit tests for it, which would flag the code as in-use. That would let us move to the next level and setup a tinderbox to detect dead code as soon as it is orphaned.

10 comments

  1. “Furthermore, I would like to point out that methods that aren’t called within Firefox are less likely to be tested and correct.”

    Having had to fix two bugs in a module merely because I was the first person to actually use them, there is a lot of truth to those words.

    What goes on in the innermost annals of dead code should probably be exorcised as fast as possible…

  2. > someone is about to use them
    just ask some old nscp folks who is gess and you will learn tons of mozilla history (http://www.mozillazine.org/talkback.html?article=872)

  3. Dear Taras,

    please don’t fuck my shit up. I know where you live.

    -pvh

  4. Dear Taras,
    please do fuck the shit up some more.
    I like your work trying to keep the codebase as small and understandable as possible.

  5. I’m surprised you’ve found so few unused functions. In my experience of enterprise software, the first time I run static analyzers over the code it finds huge chunks which were written but never called. No-one respects YAGNI in the enterprise.

  6. I found a few thousand of them, takes time to test & file bugs for all the dead code. I suppose I need more automation. Once I’m satisfied that the finder is solid, I’ll probably throw more automation at it.

  7. Has Mozilla officially discontinued BeOS support support? Shame considering Haiku is approaching alpha and could do with a decent web browser.

  8. There are still OS/2 and Beos builds around.
    The builds doesn’t come from Mozilla.org but from contributors.

    That means that you shouldn’t remove OS/2 and Be4os code.

  9. You should be careful there, as unsupporting stuff used inside “our” trees is hopefully not what we want – and I consider comm-central to be part of “our” trees. Note that just because Firefox doesn’t use some code, that doesn’t mean that we don’t have thousands of people using it. SeaMonkey, which is probably the application from our codebase that has the smallest user base, still has about a thousand people using self-built and nightly builds from the hg/1.9.1 codebase. There are even more people jumping on Alphas and Betas, and even significantly more users of much of the code in Thunderbird and Sunbird/Lightning – all of which are comm-central-based and I’d consider them “in-tree”.
    And then we probably have functionality exposed for third-party add-ons and XULRunner apps, which we might not use as much in-tree but which we don’t want to lose.

    On the other hand, getting rid of really unused and unneeded code is surely a good idea.

  10. Don’t get me wrong, I’m not advocating keeping code bloat. I’m just saying, don’t assume because Firefox doesn’t use something that it’s okay to delete it.