Re: Performance benefits of rep/loop?
From: Toby Thain (toby_at_telegraphics.com.au)
Date: 05/24/04
- Previous message: TenThumbs: "Re: (too much) allocated memory"
- In reply to: michael: "Re: Performance benefits of rep/loop?"
- Next in thread: michael: "Re: Performance benefits of rep/loop?"
- Reply: michael: "Re: Performance benefits of rep/loop?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 24 May 2004 18:01:18 +0000 (UTC)
michael.moy.1995@alum.bu.edu (michael) wrote in message news:<ddd91048.0405231928.7367d559@posting.google.com>...
> ...
> At the moment, I'm looking at doing something for constructs like
>
> if (strcmp(a, "featurea")==0) ||
> (strcmp(a, "featureb")==0) ||
> .
> .
> .
> .
> do x.
>
Have you considered using a hash table? This could be a big win if you
have more than a few tests (the one-off cost of computing the hash on
string "a" could be dwarfed by the costs of repeated strcmp's).
If the probability of a match is low, a hash table is an even better
idea, as the first hash table miss means no string matches (without
having to test any further). In your method above, to determine that
"a" matches none, you'd have to test against every string, potentially
a large expense.
(Hash comparisons are relatively cheap: e.g. longwords.)
T
- Previous message: TenThumbs: "Re: (too much) allocated memory"
- In reply to: michael: "Re: Performance benefits of rep/loop?"
- Next in thread: michael: "Re: Performance benefits of rep/loop?"
- Reply: michael: "Re: Performance benefits of rep/loop?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|