#1 Yesterday 06:48:26

Kabiri
Member
Registered: 2024-06-22
Posts: 104

FormatUtf8: Is there an internal limit on the number of arguments?

Does mORMot 2 have an internal limit on the number of arguments that can be passed to `FormatUtf8`?

When I pass more than 31 arguments, I get the following exception:

`ESynException: TFormatUtf8: too many arguments`

Is there a built-in limit, or am I doing something wrong?

Offline

#2 Yesterday 16:48:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,558
Website

Re: FormatUtf8: Is there an internal limit on the number of arguments?

There is a limit indeed.

It is hardcoded.

Offline

#3 Yesterday 17:33:20

Kabiri
Member
Registered: 2024-06-22
Posts: 104

Re: FormatUtf8: Is there an internal limit on the number of arguments?

Was there a specific reason for that? Does it cause any additional issues?

Offline

#4 Yesterday 20:09:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,558
Website

Re: FormatUtf8: Is there an internal limit on the number of arguments?

Some temporary allocation is done on the stack, and 31 parameters take 3KB.

Offline

#5 Yesterday 20:11:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,558
Website

Re: FormatUtf8: Is there an internal limit on the number of arguments?

Do you really pass more than 31 arguments to FormatUtf8?
How could it stay on the same line of code?

Use a TTextWriter or a TSynTempAdder then. wink

Offline

#6 Today 06:21:20

Kabiri
Member
Registered: 2024-06-22
Posts: 104

Re: FormatUtf8: Is there an internal limit on the number of arguments?

Yes, I really did. smile I needed to pass 37 arguments to FormatUtf8.
For now, I split it into two calls and concatenate the results:

FormatUtf8(...) + FormatUtf8(...)

Thanks for the suggestion! I'll also take a look at TTextWriter and TSynTempAdder.

Last edited by Kabiri (Today 06:22:15)

Offline

#7 Today 12:30:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,558
Website

Re: FormatUtf8: Is there an internal limit on the number of arguments?

I have enhanced to up to 40 arguments - and may be more for %%% patterns.
https://github.com/synopse/mORMot2/commit/149397043

cool

Offline

#8 Today 13:22:40

Kabiri
Member
Registered: 2024-06-22
Posts: 104

Re: FormatUtf8: Is there an internal limit on the number of arguments?

Thanks cool

Offline

Board footer

Powered by FluxBB