xdebug/xdebug — pull request #138 by danslo (2014-12-21 19:27:17+00:00)
Title: improve handle_breakpoints performance

An earlier commit, 6c72559be41eeec065f5ff858e15d49236526fe7,
made sure that xdebug_sprintf always works with C locale. To do this,
it calls setlocale 3 times to:

- Grab the original locale.
- Set the locale to C.
- Restore the original locale.

One of the functions that calls into xdebug_sprintf is handle_breakpoints,
which can be called many times when dealing with a large codebase. In the
case of Magento 2, when preprocessing LESS files, this eventually caused
a single request to call setlocale over 8 million times. The relevant
(k)cachegrind profile can be viewed here:

![profile](http://i.imgur.com/OcGSb8u.png)

Since this particular xdebug_sprintf call doesn't change depending on
locales (it just appends a class and a function), we can simply use
snprintf in this case.

The result is pretty significant:
Before: 51,74s user 0,56s system 98% cpu 52,948 total
After: 31,57s user 0,28s system 98% cpu 32,334 total