From adb65ab322d26b262f1988d24ee5cf800e07b4bf Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sat, 22 Nov 2014 22:24:48 +0000 Subject: IPath.Equals(): dont convert paths unnecessarily. Major speedup when loading the game. Thanks to rudi_s. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3102 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UPath.pas | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/base/UPath.pas b/src/base/UPath.pas index 5a0b41fd..4ce76cf0 100644 --- a/src/base/UPath.pas +++ b/src/base/UPath.pas @@ -816,12 +816,24 @@ function TPathImpl.Equals(const Other: IPath; IgnoreCase: boolean): boolean; var SelfPath, OtherPath: UTF8String; begin +{$IFDEF UNIX} + (* + It looks like the code converts correctly to UTF-8 for all input data. + Therefore, just use those (byte) strings to perform the comparision. + + NOTE: This is broken for UTF-8 strings, because file system and singstar + files might not be normalized. However, the previous code (see below in + ELSE ifdef) doesn't handle that either. So it should be fine. + *) + Result := CompareStr(Self.ToNative(), Other.ToNative()) = 0; +{$ELSE} SelfPath := Self.GetAbsolutePath().RemovePathDelim().ToUTF8(); OtherPath := Other.GetAbsolutePath().RemovePathDelim().ToUTF8(); if (FileSystem.IsCaseSensitive() and not IgnoreCase) then Result := (CompareStr(SelfPath, OtherPath) = 0) else Result := (CompareText(SelfPath, OtherPath) = 0); +{$ENDIF} end; function TPathImpl.Equals(const Other: RawByteString; IgnoreCase: boolean): boolean; -- cgit v1.2.3