Can anyone explain why strings are converted to uppercase when the hashcode is calculated?

Can anyone explain why strings are converted to uppercase when the hashcode is calculated?

function TStringHelper.GetHashCode: Integer;
var
LResult: UInt32;
I: Integer;
Temp: string;
begin
Temp := Self.ToUpper; // ?????

LResult := 0;
for I := 0 to Temp.Length - 1 do
begin
LResult := (LResult shl 5) or (LResult shr 27); //ROL Result, 5
LResult := LResult xor UInt32(Temp[I]);
end;
Result := LResult;
end;

Comments

  1. Joseph Mitzen that's what I meant by "unsupervised". No way on earth I'd let code into a SysUtils helper for a primitive type without intense code review by multiple seniors. They let this stuff out unread by any experienced developer.

    ReplyDelete
  2. Is there a QP report for any of this?

    I'd say this absolutely should be fixed - but one thing I've observed is social media posting about issues, without actually reporting it to us. I do want to encourage bugs are reported, because we do see and track those.

    ReplyDelete
  3. Whining without report is quite useless... Sometimes is hard to find is there duplicate or not...

    ReplyDelete

Post a Comment