Originally Posted By: qwerty
Believe it or not, it's normal. For example, you have a string W containing 5 * chars and you want to compare it against a 20-char string A. Each * can match from 0 to 20 chars (at most), so the number of ways W can match A is of the order of 20^5 (it's smaller, even in the worst case, but still grows exponentially with the number of *'s). In the worst case, mirc will have to do several thousands char-by-char comparisons to determine if those innocent-looking strings W and A match! So while it's possible that the wildcard matching routine could be optimised a bit, don't expect any dramatic improvements in general; in certain cases, early termination of the matching process is possible but this cannot be generalised to apply to every case.

I can't believe it and I do not understand your 20^5 exponential calculation.
Take my case.
-> wildcard search string:
*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×IDENTDBUSY
-> text string:
99×QUEUE×DalNet×riga-r.ca.us.dal.net×6668×1×IRCConnect×1×ijhsvlrz×1180326780×67×2×0×CONNECT×<unknown>×<none>×DNSFAIL×IDENTDNOTBUSY

Search routine loops through characters of wildcard string.
1) search string position 1: "*" -> wildcard symbol for any char so move on to next
2) search string position 2: "×" -> loop through text string from position 1 till character "×" found, store the position of the character after this character (pointer).
3) search string position 3: "*" -> wildcard symbol for any char so move on to next
4) search string position 4: "×" -> loop through text from previous position onwards till character "×" found, update the pointer to the position after this character.

Seach result 'false' (discarding moment) happens when the current no-wildcard symbol * being character is not found in the text string on the position of the pointer.

The outer loop (wildcard search text) does in my example case 44 iterations (the length of it), and every one of them requires a single character check on the pointer position.
I can't see any exponential component in this method.
The amount character comparisons is just the length of the wildcard search string minus the * wildcard symbols in it, i.e. the total characters that require a literal match.

I could be overlooking something of course.
I saw /filter (and also $fline() and iswm) needing 5 sec for a single line in a custom window, whereas the line had 23 tokens so the wildcard search text had 22 * wildcard symbols (see earlier in this thread).

Try for example this:
Code:
alias testiswm1 {
  var %ticks = $ticks, %i = 1
  while (%i <= 15) {
    if (*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×IDENTDBUSY !iswm 99×QUEUE×DalNet×riga-r.ca.us.dal.net×6668×1×IRCConnect×1×ijhsvlrz×1180326780×67×2×0×CONNECT×<unknown>×<none>×DNSFAIL×IDENTDNOTBUSY) { echo -ag !ISWM %i }
    inc %i
  }
  echo -ag $calc($ticks - %ticks)
}
alias testiswm2 {
  var %ticks = $ticks, %i = 1
  while (%i <= 15) {
    if (*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×*×IDENTDBUSY iswm 99×QUEUE×DalNet×riga-r.ca.us.dal.net×6668×1×IRCConnect×1×ijhsvlrz×1180326780×67×2×0×CONNECT×<unknown>×<none>×DNSFAIL×IDENTDBUSY) { echo -ag ISWM %i }
    inc %i
  }
  echo -ag $calc($ticks - %ticks)
}

The first takes 5436 ms, the second 2 ms.
The only difference is that in the first alias, the last token is NOT matched, while it is matched in the second alias, the fast (or should I say 'normal'?) one - which is also remarkable, because you only know if there is a match after checking ALL characters, while a check for a non-match may be able to discard at an earlier position, so less characters compared.

Doesn't that blow up the entire theory of alot wildcard symbols as reason?

Last edited by RRX; 28/05/07 06:30 AM.