Arguably it's an optimisation. This isn't code that is likely to change and incurring an additional function call for such a small snippet of code for the kind of processing such checks might be involved in could be a significant overhead.
They could have "inline"d it I guess, but there are all sorts of things that seem to break inlining in Delphi (as in "cause to be rejected by the compiler") and this might fall foul of those. Another explanation (perhaps also optimisation related) might lie in the fact that it isn't a perfect duplication... note the slight differences in the call that the first makes to INTERNALGetUnicodeCategory(UCS4Char), whilst the second uses GetUnicodeCategory(String, Index). Then again, this might also be a sub-optimal variation. Hard to say without probing deeper than is warranted at this point. :) On 3 June 2012 12:15, Todd <[email protected]> wrote: > 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. > _______________________________________________ > NZ Borland Developers Group - Delphi mailing list > Post: [email protected] > Admin: http://delphi.org.nz/mailman/listinfo/delphi > Unsubscribe: send an email to [email protected] with > Subject: unsubscribe >
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe
