[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Two optimization questions
From: Adriaan de Groot <adridg () cs ! kun ! nl>
Date: 2004-04-20 21:23:47
Message-ID: 200404202323.52657.adridg () cs ! kun ! nl
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[Perhaps better for kde-optimize, I know, although these questions are mostly
code-clarity vs. extremely minor performance gains.]
(1) Consider
for (QStringList::constIterator i = l.begin() ; i!=l.end(); ++i) { .. }
versus
QStringList::constIterator e = l.end();
for (QStringList::constIterator i = l.begin() ; i!=e; ++i) { .. }
Is there really a big performance hit for the first? I know KMail was looking
close at this, for huge iterations; I'm wondering what The Right Thing To Do
is, since the latter is slightly longer code, and possibly harder to
understand. What's your advice?
(2) Consider function foo(), which spans 96 lines (that's 4 screenfuls). It
consists of several identifiable blocks of functionality, so I _could_ write
it like
T foo() { doThis(); doThat(); doItWithAWhiffleBallBat(); doRest(); }
In languages like Elan, Haskell, Ocaml, I know how to do this with a minimum
of fuss, keeping the big-picture structure of foo() visible while defining it
minutely elsewhere. I'm wondering how to do this effectively in KDE C++ code.
Suppose I write:
static void doThis(.. parameters needed from locals of foo ..) { ... }
static void doThat( ... ) { ... }
...
T foo() { doThis(parms); doThat(...); ... }
What's the performance hit here? I'd hate to have real function-call overhead
for those functions, and I'd hate for them to be external symbols, since
they'd slow down linkage to no effect. Can I count on the compiler to inline
these in foo?
(2a) Alternatively, just for code clarity, when is kate going to get folding
that is persistent across loads and saves, like the venerable ae editor on
OS/2 had? Then I could fold up foo() into its logical parts and dispense with
splitting it out entirely.
- --
pub 1024D/FEA2A3FE 2002-06-18 Adriaan de Groot <groot@kde.org>
Would you like a freem?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAhZTodqzuAf6io/4RAiXRAJ9vBBridl2jITAmn/ekJBYJ5+c1JgCdGiM8
9aaFxms1tGZjqX830HhASqQ=
=tENg
-----END PGP SIGNATURE-----
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic