Recent

Author Topic: [SOLVED] Optimization for LazUtils FileExistsUTF8  (Read 349 times)

Alextp

  • Hero Member
  • *****
  • Posts: 1153
    • UVviewsoft
[SOLVED] Optimization for LazUtils FileExistsUTF8
« on: October 03, 2020, 12:27:57 am »
a) on unix, FileExistsUTF8 calls sysutils.FileExists(UTF8ToSys()).
here it can be simpler, by deleting UTF8ToSys().

b) on win32, FileExistsUTF8 calls sysutils.FileExists(UTF8ToSys()).
then code calls UnicodeString variant of sysutils.FileExists.
so we do
utf8 -> sys_cp -> UnicodeString
which can be replaced with 1 call UTF8Decode.

a) is micro optimization.
b) is bigger one.
« Last Edit: October 04, 2020, 07:38:04 am by Alextp »

lainz

  • Hero Member
  • *****
  • Posts: 3809
  • Leandro Diaz
Re: Some optimization for LazUtils FileExistsUTF8
« Reply #1 on: October 03, 2020, 04:46:37 am »
Bugtracker?

At least is not ignored only here  ::)
https://lainz.github.io/
Download LazPaint https://lazpaint.github.io/
Download BGRABitmap and BGRAControls https://github.com/bgrabitmap

Bart

  • Hero Member
  • *****
  • Posts: 4045
    • Bart en Mariska's Webstek
Re: Some optimization for LazUtils FileExistsUTF8
« Reply #2 on: October 03, 2020, 09:55:34 pm »
a) on unix, FileExistsUTF8 calls sysutils.FileExists(UTF8ToSys()).
here it can be simpler, by deleting UTF8ToSys().

b) on win32, FileExistsUTF8 calls sysutils.FileExists(UTF8ToSys()).
..
which can be replaced with 1 call UTF8Decode.

b) is bigger one.

In trunk the Windows implementation is:
Result := SysUtils.FileExists(Filename);
See also the Lazarus 2.2.0 release notes.
This will work even if users have defined DisableUTF8RTL, Utf8Decode assumes the input is UTF8, which is not the case in this scenario.

On *nix if your locale is NOT Utf8, UTF8ToSys is not a no-op.

So, IMO this should be kept as it is now (in trunk).

Bart

 

TinyPortal © 2005-2018