readDate in KLocale
David Faure
david at mandrakesoft.com
Wed Aug 7 09:05:58 BST 2002
-----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 at mandrakesoft.com, faure at 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-----
More information about the kde-core-devel
mailing list