[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: koffice/kspread
From:       Marijn Kruisselbrink <m.kruisselbrink () student ! tue ! nl>
Date:       2010-09-01 7:09:46
Message-ID: 201009010909.46712.m.kruisselbrink () student ! tue ! nl
[Download RAW message or body]

On Wednesday 01 September 2010 08:49:00 zander@kde.org wrote:
> We are talking about stuff like;
> +    static const QString sPercentage = QString::fromAscii("percentage");
>
> Using QLatin1String there is equivalent to using  const char *. While that
> saves memory, you should notice that the QLatin1String has no internal
> storage other than the char pointer.
> In other words; you will get conversions to UTF-16 on every usage, there is
> no caching done.
Ah, yes, you're right. QLatin1String would only be helpful if the strings are 
only directly compared with QStrings (but then using just a const char* would 
work just as well), but since here I'm passing nearly all of these strings to 
methods that need a QString, the conversion would still happen.

> I do suggest changing the 'fromAscii' to 'fromLatin1' as they are
> functionally equivalent for most setups, but fromAscii goes via a plugin
> and thus is slightly slower and second can change behavior if someone set a
> different QTextCodec::codecForCStrings
Ah, okay; I guess I should have read the documentation for the various 
QString::from* functions. I figured ascii would probably be a rather safe one 
to pick, but yeah, latin1 would be better.

Marijn

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic