[Lazarus] LConvEncoding- why inline func?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] LConvEncoding- why inline func?

Free Pascal - Lazarus mailing list
procedure InternalUTF8ToCP(const s: string; TargetCodePage: TSystemCodePage;
   SetTargetCodePage: boolean;
   const UTF8CharConvFunc: TUnicodeToCharID;
   out TheResult: RawByteString); inline;
begin
   if not Assigned(UTF8CharConvFunc) then
   begin
     TheResult:=s;
     SetCodePage(TheResult, TargetCodePage, True);
     if not SetTargetCodePage then
       SetCodePage(TheResult, CP_ACP, False);
   end else begin
     TheResult:=UTF8ToSingleByte(s,UTF8CharConvFunc);
     if SetTargetCodePage then
       SetCodePage(TheResult, TargetCodePage, False);
   end;
end;

Func is complex, why it's inline?

--
Regards,
Alexey

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] LConvEncoding- why inline func?

Free Pascal - Lazarus mailing list
On Thu, 3 May 2018 22:15:31 +0300
AlexeyT via Lazarus <[hidden email]> wrote:

> procedure InternalUTF8ToCP(const s: string; TargetCodePage: TSystemCodePage;
>    SetTargetCodePage: boolean;
>    const UTF8CharConvFunc: TUnicodeToCharID;
>    out TheResult: RawByteString); inline;
> begin
>    if not Assigned(UTF8CharConvFunc) then
>    begin
>      TheResult:=s;
>      SetCodePage(TheResult, TargetCodePage, True);
>      if not SetTargetCodePage then
>        SetCodePage(TheResult, CP_ACP, False);
>    end else begin
>      TheResult:=UTF8ToSingleByte(s,UTF8CharConvFunc);
>      if SetTargetCodePage then
>        SetCodePage(TheResult, TargetCodePage, False);
>    end;
> end;
>
> Func is complex, why it's inline?

It is not supposed to be used directly. It is supposed to be used by a
few other functions, which are called a lot.

Mattias
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus