~vanvugt/compiz/fix-1097664

« back to all changes in this revision

Viewing changes to plugins/opengl/src/screen.cpp

  • Committer: Tarmac
  • Author(s): Daniel van Vugt
  • Date: 2013-01-02 10:58:42 UTC
  • mfrom: (3532.1.2 re)
  • Revision ID: tarmac-20130102105842-4h0o14gx75fc7750
Avoid calling code that results in calls to regexec as much as possible. 
Regular expression matching is too expensive to do very often and compiz
was spending 31% of its CPU time in regexec().
(LP: #1095001)
. Fixes: https://bugs.launchpad.net/bugs/1095001.

Approved by Sam Spilsbury, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1248
1248
    rootPixmapSize (),
1249
1249
    glVendor (NULL),
1250
1250
    glRenderer (NULL),
1251
 
    glVersion (NULL)
 
1251
    glVersion (NULL),
 
1252
    prevRegex (),
 
1253
    prevBlacklisted (false)
1252
1254
{
1253
1255
    ScreenInterface::setHandler (screen);
1254
1256
}
2155
2157
bool
2156
2158
PrivateGLScreen::driverIsBlacklisted (const char *regex) const
2157
2159
{
2158
 
    return blacklisted (regex, glVendor, glRenderer, glVersion);
 
2160
    /*
 
2161
     * regex matching is VERY expensive, so only do it when the result might
 
2162
     * be different to last time. The gl* variables never change value...
 
2163
     */
 
2164
    if (prevRegex != regex)
 
2165
    {
 
2166
        prevBlacklisted = blacklisted (regex, glVendor, glRenderer, glVersion);
 
2167
        prevRegex = regex;
 
2168
    }
 
2169
    return prevBlacklisted;
2159
2170
}
2160
2171
 
2161
2172
GLTexture::BindPixmapHandle