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

List:       kde-commits
Subject:    Re: koffice/kspread
From:       zander () kde ! org
Date:       2010-09-01 6:49:00
Message-ID: 201009010849.01167.zander () kde ! org
[Download RAW message or body]

On Tuesday 31. August 2010 22.02.22 Marijn Kruisselbrink wrote:
> On Tuesday 31 August 2010 21:13:35 Carlos Licea wrote:
> > > SVN commit 1170195 by mkruisselbrink:
> > > 
> > > eliminate a lot of useless qstring creation/deleting, this speeds
> > > loading up again quite a bit
> > > 
> > >  M  +61 -34    Cell.cpp
> > >  M  +29 -15    Sheet.cpp
> > 
> > I wonder if you could save a bit of memory by using QLatin1Strings
> > instead of plain QStrings. QString uses UTF16 (IIRC) while all those
> > strings can be represented by plain ASCII.
> 
> Yeah, good point; although it of course would be only a rather
> insignificant amount of memory saved, but it still would be nicer indeed.

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.

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
-- 
Thomas Zander
[prev in list] [next in list] [prev in thread] [next in thread] 

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