[DUG] Why re-use when you can duplicate!

Todd todd.martin.nz at gmail.com
Sun Jun 3 12:15:14 NZST 2012


Is this a representative example of the code quality Embarcadero is
producing today?

class function TCharacter.IsNumber(C: Char): Boolean;
begin
  if not IsLatin1(C) then
    Result := CheckNumber(InternalGetUnicodeCategory(UCS4Char(C)))
  else if not IsAscii(C) then
    Result := CheckNumber(InternalGetLatin1Category(C))
  else
    Result := (C >= '0') and (C <= '9');
end;

class function TCharacter.IsNumber(const S: string; Index: Integer):
Boolean;
var
  C: Char;
begin
  CheckStringRange(S, Index);
  C := S[Index];
  if not IsLatin1(C) then
    Result := CheckNumber(GetUnicodeCategory(S, Index))
  else if not IsAscii(C) then
    Result := CheckNumber(InternalGetLatin1Category(C))
  else
    Result := (C >= '0') and (C <= '9');
end;

Todd.


More information about the Delphi mailing list