Words cannot describe... Data.DB.pas, TNamedItem.HashName Get link Facebook X Pinterest Email Other Apps - October 29, 2013 Words cannot describe... Data.DB.pas, TNamedItem.HashName... Get link Facebook X Pinterest Email Other Apps Comments Nicholas RingOctober 29, 2013 at 1:22 PMThat good, eh? ;-)ReplyDeleteRepliesReplyAsbjørn HeidOctober 29, 2013 at 1:59 PMIt's amazing... so much micro optimizations, and then failing so hard on the big stuff. For those who can't check it out, here's the best bit: if Len > BufferLen then GetMem(Data, Len * SizeOf(Char)) else Data :=@Buffer[0]; Move(Pointer(AnsiUpperCase(Name))^, Data^, Len * SizeOf(Char));What does AnsiUpperCase do? It of course allocates a brand new string, copies the data over and then calls CharUpperBuff (on Windows).And what does the HashName code do with this "Data" array? It simply loops over each character to compute the hash...ReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
That good, eh? ;-)
ReplyDeleteIt's amazing... so much micro optimizations, and then failing so hard on the big stuff. For those who can't check it out, here's the best bit:
ReplyDeleteif Len > BufferLen then
GetMem(Data, Len * SizeOf(Char))
else
Data :=@Buffer[0];
Move(Pointer(AnsiUpperCase(Name))^, Data^, Len * SizeOf(Char));
What does AnsiUpperCase do? It of course allocates a brand new string, copies the data over and then calls CharUpperBuff (on Windows).
And what does the HashName code do with this "Data" array? It simply loops over each character to compute the hash...