Re: Performance benefits of rep/loop?

From: Toby Thain (toby_at_telegraphics.com.au)
Date: 05/24/04

  • Next message: Robert Redelmeier: "Re: LDS instruction?"
    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


  • Next message: Robert Redelmeier: "Re: LDS instruction?"

    Relevant Pages

    • Re: Need quick lookup like Hashtable, but dont need to store value
      ... The cost of the individual operations. ... that container will require touching all 100 characters of the target string ... in order to compute its hash. ... For a sorted array, finding a string using a binary search will take at most ...
      (microsoft.public.dotnet.framework)
    • Re: How to write a diff in VB6 for comparing two xml files?
      ... No, the best you could do is to read both into string and use StrCompbut it's inefficient and, but using the hash ... Private Declare Function CryptAcquireContext Lib "AdvAPI32.dll" Alias _ ... Dim HashAAs Byte, HashLenA As Long ...
      (microsoft.public.vb.general.discussion)
    • Re: something like switch in c
      ... >> straightforward string comparisions. ... > inner table size and/or add symbols to expand the hash. ... It all depends on the empirical pattern of the actual keys. ... The value of the random number generator is UNCHANGED on ...
      (comp.programming)
    • Re: How to make PKCS#7 signature using CryptoAPI?
      ... Those MSDN samples hash a string PLUS the null byte (so that it ... I tried your sample and had no problem verifying with openssl (after I added ... functions (including CryptSignMessage). ...
      (microsoft.public.platformsdk.security)
    • Re: How to make PKCS#7 signature using CryptoAPI?
      ... "Mitch Gallant" wrote: ... Those MSDN samples hash a string PLUS the null byte (so that it ... functions (including CryptSignMessage). ...
      (microsoft.public.platformsdk.security)

    Loading