#1 2015-08-27 20:40:01

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

IntegerDynArrayToCSV

Could IntegerDynArrayToCSV change it's behaviour so that the Prefix and Suffix are returned with an empty array?

It would need the following changes at line 22603 of SynCommons.pas:

function IntegerDynArrayToCSV(const Values: array of integer; ValuesCount: integer;
  const Prefix: RawUTF8=''; const Suffix: RawUTF8=''): RawUTF8;
type
  TInts16 = packed array[word] of string[15]; // shortstring are faster (no heap allocation)
var i, L, Len: PtrInt;
    tmp: array[0..15] of AnsiChar;
    ints: ^TInts16;
    P: PAnsiChar;
begin
  result := '';
  if ValuesCount=0 then
    exit;
...

to

function IntegerDynArrayToCSV(const Values: array of integer; ValuesCount: integer;
  const Prefix: RawUTF8=''; const Suffix: RawUTF8=''): RawUTF8;
type
  TInts16 = packed array[word] of string[15]; // shortstring are faster (no heap allocation)
var i, L, Len: PtrInt;
    tmp: array[0..15] of AnsiChar;
    ints: ^TInts16;
    P: PAnsiChar;
begin
  result := '';
  if ValuesCount=0 then begin
    result := Prefix + Suffix;
    exit;
  end;
...

The following Int64DynArrayToCSV function would need the same change for consistency.

Offline

#2 2015-08-28 06:40:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,663
Website

Re: IntegerDynArrayToCSV

It would break existing code, I'm afraid.

Use your own function, instead:

function EsmondIntegerDynArrayToCSV(const Values: array of integer; ValuesCount: integer;
  const Prefix: RawUTF8=''; const Suffix: RawUTF8=''): RawUTF8;
begin
  if ValuesCount=0 then begin
    result := Prefix + Suffix else
    result := IntegerDynArrayToCSV(Values,ValuesCount,Prefix,Suffix);
end;

Offline

Board footer

Powered by FluxBB