Am Samstag, 18. November 2006 13:57 schrieb Andre Poenitz: > On Sat, Nov 18, 2006 at 10:55:38AM +0100, Jean-Marc Lasgouttes wrote: > > >>>>> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes: > > > > Andre> I don't understand the difference. > > > > Easy: the new one works :) > > That's what I suspected, yet I did not see the reasone. > > > More precisely, the string is now a docstring and tricks with > > null-terminated strings are not working anymore. If your problem is > > with the use of convert, it may be possible to do something else. > > But we'd insert a 'wide' 0 as terminator, so I still don't see it.
I think the problem is exactly the inserted 0. This is not standard conformant as I wrote in my last mail. Why should any function that operates on a std::string scan for 0 characters in the content to determine the length when there is std::string::length()? > (Btw the hack was there because it showed up in the proiler at some > time. Maybe times have schanged since then, but once there was a > reason...) You should have added a comment about the profiler. If this is still performance critical then the attached patch should work. No cast is needed, since all possible numeric values of '0' + n are in the range of 48..57, which does not have any issues with signedness. At least this version is 100% standard conformant, but I don't have time to check whether it is needed. Georg
Index: src/mathed/MathMacroArgument.C =================================================================== --- src/mathed/MathMacroArgument.C (Revision 15972) +++ src/mathed/MathMacroArgument.C (Arbeitskopie) @@ -34,7 +34,12 @@ MathMacroArgument::MathMacroArgument(siz lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: " << n << endl; } - str_ = '#' + convert<docstring>(n); + // The profiler tells us not to use + // str_ = '#' + convert<docstring>(n); + // so we do the conversion of n to ASCII manually. + str_.resize(2); + str_[0] = '#'; + str_[1] = '0' + n; }