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

List:       kde-devel
Subject:    Re: KConfig again
From:       Kalle Dalheimer <kalle () dalheimer ! de>
Date:       1999-05-17 7:38:23
[Download RAW message or body]

Harri Porten wrote:
> 
> Mosfet wrote:
> >
> > On Sun, 16 May 1999, Christoph Neerfeld wrote:
> > > On 17-May-99 Mosfet wrote:
> > > >
> > > > And also how KConfig is used. As I mentioned before, almost all apps read in
> > > > the KConfig items they want in their constructors and put them in local data
> > > > structures. They do not call readEntry a bunch of times throughout the
> > > > program.
> > >
> > > I don't know what other developers do, but I tend to keep the information in
> > > config objects and don't copy it to local variables. But of course I would do it
> > > if I knew that KConfig rereads the file every time.
> >
> > This does not seem to be a good idea in any case. If you need to access a key
> > many times it seems better to load it into a variable than calling KConfig over
> > and over.

calling readEntry() is quite fast

- two function calls
- one hash table lookup

OK, this is of course more than one memory access, but still not much.
Again, it is a trade-off of speed against memory whether you should copy
the data into local variables.

On the other hand, if you copy the data into local variables and then
change it, you must always remember to write it back into the KConfig
object at some point.

Kalle

-- 
Kalle Dalheimer              Contract programming for Unix
kalle@dalheimer.de           Technical writing
kalle@kde.org                Technical editing
kalle@oreilly.de             KDE Developer (MFCH)
mdalheimer@acm.org           It's open, it's source, it runs - must be
KDE!

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

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