Recent

Author Topic: [SOLVED] Simplified ExcludeLeadingPathDelimiter  (Read 771 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 390
[SOLVED] Simplified ExcludeLeadingPathDelimiter
« on: August 29, 2023, 10:43:38 am »
rtl/objpas/sysutils/fina.inc has
Code: Pascal  [Select][+][-]
  1. function ExcludeLeadingPathDelimiter(Const Path: PathStr): PathStr;
  2.  
  3. Var
  4.   L : Integer;
  5.  
  6. begin
  7.   Result:=Path;
  8.   L:=Length(Result);
  9.   If (L>0) and CharInSet(Result[1],AllowDirectorySeparators) then
  10.     Delete(Result,1,1);
  11. end;
After replacing "If (L>0)" with "If (Result<>'')" and removing the variable "L", the function becomes:
Code: Pascal  [Select][+][-]
  1. function ExcludeLeadingPathDelimiter(Const Path: PathStr): PathStr;
  2. begin
  3.   Result:=Path;
  4.   If (Result<>'') and CharInSet(Result[1],AllowDirectorySeparators) then
  5.     Delete(Result,1,1);
  6. end;

A patch is attached.
« Last Edit: August 29, 2023, 12:10:24 pm by lagprogramming »

Fibonacci

  • Full Member
  • ***
  • Posts: 219
  • #PDK
Re: Simplified ExcludeLeadingPathDelimiter
« Reply #1 on: August 29, 2023, 10:46:45 am »
Why don't you submit these patches on gitlab?

AlexTP

  • Hero Member
  • *****
  • Posts: 2292
    • UVviewsoft

AlexTP

  • Hero Member
  • *****
  • Posts: 2292
    • UVviewsoft
Re: Simplified ExcludeLeadingPathDelimiter
« Reply #3 on: August 29, 2023, 11:07:58 am »
Sorry for the last comment-- I misread the code and 'found' for-loop.

Fibonacci

  • Full Member
  • ***
  • Posts: 219
  • #PDK
Re: Simplified ExcludeLeadingPathDelimiter
« Reply #4 on: August 29, 2023, 11:09:57 am »
Yeah I was wondering where is that loop :D

 

TinyPortal © 2005-2018