From Farshid Lashkari, "I have a scene that makes heavy use of the StateSet::compare method and my profiler showed that a lot of time was being spent inside it. I made a small change to the method so that it performs a quick size comparison between the attribute/mode lists and bin mode before iterating through all the attributes. This made a noticeable improvement in my scene. I've attached the change."