KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've seen comments on SO saying " <> is faster than = " or " != faster than == " in an if() statement. I'd like to know why is that so. Could you show an example in asm? Thanks! :) EDIT: Source Here is what he did. function Check(var MemoryData:Array of byte;MemorySignature:Array of byte;Position:integer):boolean; var i:byte; begin Result := True; //moved at top. Your function always returned 'True'. This is what you wanted? for i := 0 to Length(MemorySignature) - 1 do //are you sure??? Perhaps you want High(MemorySignature) here... begin {!} if MemorySignature[i] <> $FF then //speedup - '<>' evaluates faster than '=' begin Result:=memorydata[i + position] <> MemorySignature[i]; //speedup. if not Result then Break; //added this! - speedup. We already know the result. So, no need to scan till end. end; end; end;
Tags (comma-separated)
Save Edits
Cancel