[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: readDate in KLocale
From: David Faure <david () mandrakesoft ! com>
Date: 2002-08-07 8:05:58
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday 06 August 2002 23:36, Jacek Stolarczyk wrote:
> Hi,
>
> Is there any specific reason why "for" loops are used for month names and day
> names? (instead of "while"). Unless I'm missing something here it looks
> rather inefficient.
>
> example snippet:
> error = true;
> for (int j = 1; j < 8; j++) {
> QString s = weekDayName(j, c == 'a').lower();
> int len = s.length();
> if (str.mid(strpos, len) == s)
> {
> strpos += len;
> error = false;
> }
> }
No need to switch to a while() (with the risk to forget initialization or j++ somewhen).
Simply doing
for (int j = 1; j < 8 && error; j++) {
will abort the loop when a match is found.
(Is this what this is about?)
- --
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
Back from holidays
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9UNTm72KcVAmwbhARAsW8AJ9RBroJVNObeBdTpsks0U5ovlRUJQCeKpt6
1jsn8OTEartsmGr9k43gnW4=
=ZQiI
-----END PGP SIGNATURE-----
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic