Presenting IsEqualGUIDEx, a much more efficient extension of the
IsEqualGUID function, based on Bill T's original implementation.
Now you can compare mutiple GUIDs with just one call. The use of
this function helps simplify code.
Posted on 2003-06-07 22:57:49 by Poimander
'repz cmpsd' costs about 48 clocks while four 'mov ecx, / cmp ecx, ' cost only about 12 clocks.
Posted on 2003-06-08 21:24:23 by KomsBomb
Greetings, I didn't make any claims as to whether
IsEqualGUIDEx is optimal or not, I merely claimed that
it is more efficient. But I applaud your accute skills
of observation. In fact I challenge you to optimise
IsEqualGUIDEx as much as possible. Certainly your
contribution in this regard is important and appreciated.
I wrote IsEqualGUIDEx as a generalization of Bill T's
implementation of IsEqualGUID with the intention of
maintaining code size to a minimum.
Posted on 2003-06-09 11:30:24 by Poimander
I'm really not good at optimization :-)
Following code is assemblied by TASM(I didn't test it). I believe it can be optimized more better.
The code looks much longer than yours, but I think it's faster. We can't get both small and fast code :-)

IsEqualGUIDEx proc
arg rguid1:dword, rguid2:dword:?
uses esi

xor eax, eax
mov esi,
mov ecx,
jecxz @@notfound
inc eax
mov edx, ;1
cmp edx, ;2
jnz short @@loop ;2
mov edx, ;1
cmp edx, ;2
jnz short @@loop ;2
mov edx, ;1
cmp edx, ;2
jnz short @@loop ;2
mov edx, ;1
cmp edx, ;2
jnz short @@loop ;2 The maximum is 5*4=20 clocks
xor eax, eax
IsEqualGUIDEx endp
Posted on 2003-06-10 00:24:49 by KomsBomb
Or readable :)
Posted on 2003-06-10 00:43:31 by RobotBob
Personally, I'll keep using the Windows API for the comparison.


Posted on 2003-06-10 21:48:12 by Ernie
KomsBomb your code is excellent! I have taken your lead
and developed an MMX version which also acheives 20 cycles.

push eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov STDOUT, eax
pop eax

I've updated this in the attached file:
Posted on 2003-06-11 16:19:38 by Poimander
Ernie, I find your remarks amusing. What's wrong with coding
non-standard functions?
Posted on 2003-06-11 22:00:04 by Poimander
Ernie's point (i think) is basically that:

1) The function is not complex enought to notice any substantial difference in practice (even tho yours may be faster to execute).

2) To use your optomized version, implies the Microsoft API for this is going to be abandoned and hence your source becomes non-standard. Should Microsoft decided to make wild changes to the internals of their API's and overall functionality in COM, your routine would be left in the dark (and not operate with any reliability in this case on future operating systems). Your non-standard version would also require upgrading, and any sources you used your routine in would require re-compiling. etc. etc. etc.

Posted on 2003-06-11 22:05:53 by NaN
NaN, your comments are well taken. However IsEqualGUIDEx
is not a replacement of an existing API, but merely a function
modeled after after an existing API. Since IsEqualGUIDEx is
relatively simple in that it doesn't depend on any external APIs,
upgrade considerations are non-existent (after all the function
merely compares 128-bit numbers).

I think if you were to take a look a Xtreme's excellent WebBrowser
code then you would immediately recognize the utility of this
enhanced function.

Thank you for clarifying Ernie's remark. I'm new to the board and
therefore didn't fully appreciate his reference to 'non-standard'.
Now I do. I think part of the confusion may be the result of the
chosen name of the function which may appear to be presump-
-tuous to some, if that is the case, mea culpa.
Posted on 2003-06-11 22:54:49 by Poimander
Hi Poimander,

your post is welcome and appreciated. And the "speed" question has only come up because of KomsBomb reply. I use a somewhat similiar function which is really useful if implementing QueryInterface for objects exposing more that just 1 or 2 interfaces.

Posted on 2003-06-12 07:37:05 by japheth
Greetings Japheth,

Thank you for your polite and precise summary.
Posted on 2003-06-12 18:56:01 by Poimander