* Jonathan Wakely:

> Where __detail::__lookup_collatename is a non-template function like
> this:
>
>    inline void
>    __lookup_collatename(string& __name)
>    {
>      static const char* const __collatenames[] =
>        {
>       "NUL",
>       "SOH",
>          ...
>       "tilde",
>       "DEL",
>        };
>
>      for (const auto& __it : __collatenames)
>        if (__s == __it)
>       {
>         __s.assign(1, static_cast<char>(&__it - __collatenames));
>         return;
>       }
>
>      __s.clear();
>    }
>
>
> This way we only call narrow/widen when we don't already have a string
> of char, and we only emit that array of strings into the binary once.

You could also use "NUL\0" "SOH\0" … "\0\0", and use explicitly strlen
and memcmp calls during the iteration.  This avoids adding dozens of
run-time relocations.

Reply via email to