patch adds inline to NN tiny functions.

--
Regards,
Alexey

Index: components/lazutils/lazutf8.pas
===================================================================
--- components/lazutils/lazutf8.pas	(revision 59373)
+++ components/lazutils/lazutf8.pas	(working copy)
@@ -67,10 +67,10 @@
 procedure GetLocaleFormatSettingsUTF8(LCID: Integer; var aFormatSettings: TFormatSettings);
 {$endif}
 
-Function GetEnvironmentVariableCountUTF8: Integer;
-function GetEnvironmentStringUTF8(Index: Integer): string;
-function GetEnvironmentVariableUTF8(const EnvVar: string): String;
-function SysErrorMessageUTF8(ErrorCode: Integer): String;
+Function GetEnvironmentVariableCountUTF8: Integer; inline;
+function GetEnvironmentStringUTF8(Index: Integer): string; inline;
+function GetEnvironmentVariableUTF8(const EnvVar: string): String; inline;
+function SysErrorMessageUTF8(ErrorCode: Integer): String; inline;
 
 // Returns the size of one codepoint in bytes.
 function UTF8CodepointSize(p: PChar): integer; inline;
@@ -86,10 +86,10 @@
 
 // Functions dealing with unicode number U+xxx.
 function UTF8CodepointToUnicode(p: PChar; out CodepointLen: integer): Cardinal;
-function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal; deprecated 'Use UTF8CodepointToUnicode instead.';
+function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal; inline; deprecated 'Use UTF8CodepointToUnicode instead.';
 function UnicodeToUTF8(CodePoint: cardinal): string; // UTF32 to UTF8
 function UnicodeToUTF8(CodePoint: cardinal; Buf: PChar): integer; // UTF32 to UTF8
-function UnicodeToUTF8SkipErrors(CodePoint: cardinal; Buf: PChar): integer; // UTF32 to UTF8
+function UnicodeToUTF8SkipErrors(CodePoint: cardinal; Buf: PChar): integer; inline; // UTF32 to UTF8
 function UnicodeToUTF8Inline(CodePoint: cardinal; Buf: PChar): integer; inline; // UTF32 to UTF8
 function UTF8ToDoubleByteString(const s: string): string;
 function UTF8ToDoubleByte(UTF8Str: PChar; Len: PtrInt; DBStr: PByte): PtrInt;
@@ -99,14 +99,14 @@
 function Utf8TryFindCodepointStart(const AString: String; var Index: Integer; out CharLen: Integer): Boolean;
 // find the n-th UTF8 codepoint, ignoring BIDI
 function UTF8CodepointStart(UTF8Str: PChar; Len, CodepointIndex: PtrInt): PChar;
-function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar; deprecated 'Use UTF8CodepointStart instead.';
+function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar; inline; deprecated 'Use UTF8CodepointStart instead.';
 // find the byte index of the n-th UTF8 codepoint, ignoring BIDI (byte len of substr)
-function UTF8CodepointToByteIndex(UTF8Str: PChar; Len, CodepointIndex: PtrInt): PtrInt;
-function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt): PtrInt; deprecated 'Use UTF8CodepointToByteIndex instead.';
+function UTF8CodepointToByteIndex(UTF8Str: PChar; Len, CodepointIndex: PtrInt): PtrInt; inline;
+function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt): PtrInt; inline; deprecated 'Use UTF8CodepointToByteIndex instead.';
 procedure UTF8FixBroken(P: PChar); overload;
 procedure UTF8FixBroken(var S: string); overload;
 function UTF8CodepointStrictSize(P: PChar): integer;
-function UTF8CharacterStrictLength(P: PChar): integer; deprecated 'Use UTF8CodepointStrictSize instead.';
+function UTF8CharacterStrictLength(P: PChar): integer; inline; deprecated 'Use UTF8CodepointStrictSize instead.';
 function UTF8CStringToUTF8String(SourceStart: PChar; SourceLen: PtrInt) : string;
 
 function UTF8Pos(const SearchForText, SearchInText: string; StartPos: SizeInt = 1): PtrInt;
@@ -125,21 +125,21 @@
   Flags: TReplaceFlags; ALanguage: string=''): String;
 
 function UTF8LowerCase(const AInStr: string; ALanguage: string=''): string;
-function UTF8LowerString(const s: string): string;
+function UTF8LowerString(const s: string): string; inline;
 function UTF8UpperCase(const AInStr: string; ALanguage: string=''): string;
-function UTF8UpperString(const s: string): string;
+function UTF8UpperString(const s: string): string; inline;
 function UTF8SwapCase(const AInStr: string; ALanguage: string=''): string;
 // Capitalize the first letters of every word
 function UTF8ProperCase(const AInStr: string; const WordDelims: TSysCharSet): string;
 function FindInvalidUTF8Codepoint(p: PChar; Count: PtrInt; StopOnNonUTF8: Boolean = true): PtrInt;
-function FindInvalidUTF8Character(p: PChar; Count: PtrInt; StopOnNonUTF8: Boolean = true): PtrInt; deprecated 'Use FindInvalidUTF8Codepoint instead.';
+function FindInvalidUTF8Character(p: PChar; Count: PtrInt; StopOnNonUTF8: Boolean = true): PtrInt; inline; deprecated 'Use FindInvalidUTF8Codepoint instead.';
 function UTF8StringOfChar(AUtf8Char: String; N: Integer): String;
 function UTF8AddChar(AUtf8Char: String; const S: String; N: Integer): String;
 function UTF8AddCharR(AUtf8Char: String; const S: String; N: Integer): String;
-function UTF8PadLeft(const S: String; const N: Integer; const AUtf8Char: String = #32): String;
-function UTF8PadRight(const S: String; const N: Integer; const AUtf8Char: String = #32): String;
+function UTF8PadLeft(const S: String; const N: Integer; const AUtf8Char: String = #32): String; inline;
+function UTF8PadRight(const S: String; const N: Integer; const AUtf8Char: String = #32): String; inline;
 function UTF8PadCenter(const S: String; const N: Integer; const AUtf8Char: String = #32): String;
-function UTF8LeftStr(const AText: String; const ACount: Integer): String;
+function UTF8LeftStr(const AText: String; const ACount: Integer): String; inline;
 function UTF8RightStr(const AText: String; const ACount: Integer): String;
 function UTF8QuotedStr(const S, Quote: string): string;
 //Utf8 version of MidStr is just Utf8Copy with same parameters, so it is not implemented here
@@ -147,7 +147,7 @@
 function UTF8EndsText(const ASubText, AText: string): Boolean;
 function UTF8ReverseString(p: PChar; const ByteCount: LongInt): string;
 function UTF8ReverseString(const AText: string): string; inline;
-function UTF8RPos(const Substr, Source: string): PtrInt;
+function UTF8RPos(const Substr, Source: string): PtrInt; inline;
 
 function UTF8WrapText(S, BreakStr: string; BreakChars: TSysCharSet; MaxCol: integer): string; overload;
 function UTF8WrapText(S: string; MaxCol: integer): string; overload;
@@ -194,9 +194,9 @@
   Src: PWideChar; SrcWideCharCount: SizeUInt; Options: TConvertOptions;
   out ActualCharCount: SizeUInt): TConvertResult;
 
-function UTF8ToUTF16(const S: AnsiString): UnicodeString; overload;
+function UTF8ToUTF16(const S: AnsiString): UnicodeString; overload; inline;
 function UTF8ToUTF16(const P: PChar; ByteCnt: SizeUInt): UnicodeString; overload;
-function UTF16ToUTF8(const S: UnicodeString): AnsiString; overload;
+function UTF16ToUTF8(const S: UnicodeString): AnsiString; overload; inline;
 function UTF16ToUTF8(const P: PWideChar; WideCnt: SizeUInt): AnsiString; overload;
 
 // locale
@@ -355,7 +355,7 @@
   {$ENDIF}
 end;
 
-function GetEnvironmentVariableCountUTF8: Integer;
+function GetEnvironmentVariableCountUTF8: Integer; inline;
 begin
   {$IF defined(FPC_RTL_UNICODE) or not defined(MSWindows)} //also WinCE, issue #0031788
   Result:=SysUtils.GetEnvironmentVariableCount;
@@ -364,7 +364,7 @@
   {$ENDIF}
 end;
 
-function GetEnvironmentStringUTF8(Index: Integer): string;
+function GetEnvironmentStringUTF8(Index: Integer): string; inline;
 begin
   {$IFDEF FPC_RTL_UNICODE}
   Result:=UTF16ToUTF8(SysUtils.GetEnvironmentString(Index));
@@ -379,7 +379,7 @@
   {$ENDIF}
 end;
 
-function GetEnvironmentVariableUTF8(const EnvVar: string): String;
+function GetEnvironmentVariableUTF8(const EnvVar: string): String; inline;
 begin
   {$IFDEF FPC_RTL_UNICODE}
   Result:=UTF16ToUTF8(SysUtils.GetEnvironmentVariable(UTF8ToUTF16(EnvVar)));
@@ -394,7 +394,7 @@
   {$ENDIF}
 end;
 
-function SysErrorMessageUTF8(ErrorCode: Integer): String;
+function SysErrorMessageUTF8(ErrorCode: Integer): String; inline;
 begin
   Result := SysToUTF8(SysUtils.SysErrorMessage(ErrorCode));
 end;
@@ -618,7 +618,7 @@
   end;
 end;
 
-function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal;
+function UTF8CharacterToUnicode(p: PChar; out CharLen: integer): Cardinal; inline;
 begin
   Result := UTF8CodepointToUnicode(p, CharLen);
 end;
@@ -636,7 +636,7 @@
     RaiseInvalidUnicode;
 end;
 
-function UnicodeToUTF8SkipErrors(CodePoint: cardinal; Buf: PChar): integer;
+function UnicodeToUTF8SkipErrors(CodePoint: cardinal; Buf: PChar): integer; inline;
 begin
   Result:=UnicodeToUTF8Inline(CodePoint,Buf);
 end;
@@ -818,12 +818,12 @@
   end;
 end;
 
-function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar;
+function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar; inline;
 begin
   Result := UTF8CodepointStart(UTF8Str, Len, CharIndex);
 end;
 
-function UTF8CodepointToByteIndex(UTF8Str: PChar; Len, CodepointIndex: PtrInt): PtrInt;
+function UTF8CodepointToByteIndex(UTF8Str: PChar; Len, CodepointIndex: PtrInt): PtrInt; inline;
 var
   p: PChar;
 begin
@@ -833,7 +833,7 @@
   else Result := p - UTF8Str;
 end;
 
-function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt): PtrInt;
+function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt): PtrInt; inline;
 begin
   Result := UTF8CodepointToByteIndex(UTF8Str, Len, CharIndex);
 end;
@@ -953,7 +953,7 @@
     exit(0);
 end;
 
-function UTF8CharacterStrictLength(P: PChar): integer;
+function UTF8CharacterStrictLength(P: PChar): integer; inline;
 begin
   Result := UTF8CodepointStrictSize(P);
 end;
@@ -2399,7 +2399,7 @@
   SetLength(Result,OutStr - PChar(Result));
 end;
 
-function UTF8LowerString(const s: string): string;
+function UTF8LowerString(const s: string): string; inline;
 begin
   Result:=UTF8LowerCase(s);
 end;
@@ -2787,7 +2787,7 @@
   SetLength(Result,OutCounter);
 end;
 
-function UTF8UpperString(const s: string): string;
+function UTF8UpperString(const s: string): string; inline;
 begin
   Result:=UTF8UpperCase(s);
 end;
@@ -2860,7 +2860,7 @@
   Result:=-1;
 end;
 
-function FindInvalidUTF8Character(p: PChar; Count: PtrInt; StopOnNonUTF8: Boolean = true): PtrInt;
+function FindInvalidUTF8Character(p: PChar; Count: PtrInt; StopOnNonUTF8: Boolean = true): PtrInt; inline;
 begin
   Result := FindInvalidUTF8Codepoint(p, Count, StopOnNonUTF8);
 end;
@@ -2997,12 +2997,12 @@
     Result := Result + Utf8StringOfChar(AUtf8Char, N-l);
 end;
 
-function UTF8PadLeft(const S: String; const N: Integer; const AUtf8Char: String = #32): String;
+function UTF8PadLeft(const S: String; const N: Integer; const AUtf8Char: String = #32): String; inline;
 begin
   Result := Utf8AddChar(AUtf8Char, S, N);
 end;
 
-function UTF8PadRight(const S: String; const N: Integer; const AUtf8Char: String = #32): String;
+function UTF8PadRight(const S: String; const N: Integer; const AUtf8Char: String = #32): String; inline;
 begin
   Result := Utf8AddCharR(AUtf8Char, S, N);
 end;
@@ -3021,7 +3021,7 @@
     Result := S;
 end;
 
-function UTF8LeftStr(const AText: String; const ACount: Integer): String;
+function UTF8LeftStr(const AText: String; const ACount: Integer): String; inline;
 begin
   Result := Utf8Copy(AText,1,ACount);
 end;
@@ -3110,7 +3110,7 @@
   Result := UTF8ReverseString(PChar(AText), length(AText));
 end;
 
-function UTF8RPos(const Substr, Source: string): PtrInt;
+function UTF8RPos(const Substr, Source: string): PtrInt; inline;
 var
   pRev: PtrInt;
 begin
@@ -3772,7 +3772,7 @@
   Avoid copying the result string since on windows a widestring requires a full
   copy
  ------------------------------------------------------------------------------}
-function UTF8ToUTF16(const S: AnsiString): UnicodeString;
+function UTF8ToUTF16(const S: AnsiString): UnicodeString; inline;
 begin
   Result:=UTF8ToUTF16(PChar(S),length(S));
 end;
@@ -3798,7 +3798,7 @@
 
   Converts the specified UTF-16 encoded string (system endian) to UTF-8 encoded
  ------------------------------------------------------------------------------}
-function UTF16ToUTF8(const S: UnicodeString): AnsiString;
+function UTF16ToUTF8(const S: UnicodeString): AnsiString; inline;
 begin
   Result := UTF16ToUTF8(PWideChar(S),length(S));
 end;
-- 
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to