On fpc_*_concat_multi involving only one nonempty string, return it directly if possible.

Patch: multi.patch.

USE CASE:

displayedName := IfThen(stolen, '!', '') + 'pile of bones' + IfThen(stolen, '!', '');

This also removes several redundant actions, either as a no-brainer or relying on that Moveing zero bytes is a fast enough no-op. In particular, why would you purposely move null terminators (Size + 1 characters instead of Size).

This can change the behavior slightly: if the only nonempty input string had a placeholder codepage and the requested codepage was “semantically equivalent”, result (remains the new reference to the same string and therefore) retains the placeholder. I think this is more consistent, as the following code:

{$mode objfpc} {$longstrings on}
var
	a, b, empty: string;
begin
	DefaultSystemCodePage := 12345;
	empty := '';

	a := empty + 'A' + empty;
	writeln('concat_multi codepage:   ', StringCodePage(a));

	b := empty + 'B';
	b := b + empty;
	writeln('concat, concat codepage: ', StringCodePage(b));
end.

outputs

concat_multi codepage:   12345
concat, concat codepage: 0

before the patch, and

concat_multi codepage:   0
concat, concat codepage: 0

after the patch.

Edited by Rika