[RFA] Processing locale::_M_names decently fast

Paolo Carlini pcarlini@suse.de
Sat May 1 12:49:00 GMT 2004


Paolo Carlini wrote:

> Now, back to work!

Ok, the below is what I have prepared and tested.

In order to make possible dealing easily with changes to the standard
in this area (thanks again Martin!) I chose to represent an unnamed
locale as, simply, _M_names[0] == 0; all the categories the same name
as _M_names[1] == 0. Of course, we are still able to deal, as a slower
fall back, with all _M_names[i] != 0 and equal - this can be produced
by a sequence of locale functions - a "simple" name() is correctly
returned in this case too. Similarly, in the future will be able to
accomodate possible "complex" unnamed locales, characterized by "*"
in some _M_names[i], actual names in others.

I hope the Changelog and the comments are sufficienlty clear: I like,
besides the performance improvements, the resulting nice cleanup and
simplification of many functions!

Some numbers, now (P4-2400, -O2):

  locale loc1("en_US");
  locale loc2("en_US");
  for (long i = 0; i < 10000000; ++i)
    if (loc1 != loc2)
      abort();

current
-------
3.280u 0.010s 0:03.28 100.3%    0+0k 0+0io 248pf+0w

patched
-------
0.320u 0.000s 0:00.32 100.0%    0+0k 0+0io 247pf+0w

//-------------------------------------------------

  locale loc1("en_US");
  locale loc3("fr_FR");
  for (long i = 0; i < 10000000; ++i)
    if (loc1 == loc3)
      abort();

current
-------
0.710u 0.000s 0:00.73 97.2%     0+0k 0+0io 248pf+0w

patched
-------
0.220u 0.000s 0:00.22 100.0%    0+0k 0+0io 247pf+0w

//-------------------------------------------------

  locale loc1("en_US");
  locale loc2("en_US");
  for (long i = 0; i < 10000000; ++i)
    if (loc1.name() != loc2.name())
      abort();

current
-------
9.950u 0.210s 0:10.18 99.8%     0+0k 0+0io 251pf+0w

patched
-------
5.480u 0.000s 0:05.50 99.6%     0+0k 0+0io 250pf+0w

//-------------------------------------------------

I would commit this, say, tomorrow or monday morning, barring
further comments.

Thanks,
Paolo.

///////////////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_locale_encoding
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20040501/357799a2/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_locale_encoding
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20040501/357799a2/attachment-0001.ksh>


More information about the Libstdc++ mailing list