diff --git a/Source/Simba.lpi b/Source/Simba.lpi
index 15a4fd2bd..5e2c49f16 100644
--- a/Source/Simba.lpi
+++ b/Source/Simba.lpi
@@ -340,7 +340,7 @@
-
+
@@ -1021,6 +1021,10 @@
+
+
+
+
diff --git a/Source/algorithms/simba.algo_unique.pas b/Source/algorithms/simba.algo_unique.pas
index 6f85fbe08..93e0530e5 100644
--- a/Source/algorithms/simba.algo_unique.pas
+++ b/Source/algorithms/simba.algo_unique.pas
@@ -26,7 +26,7 @@ function Algo_Unique_String(const Arr: TStringArray): TStringArray;
implementation
uses
- simba.tpa, simba.overallocatearray, simba.math;
+ simba.tpa, simba.arraybuffer, simba.math;
generic function Unique(const Arr: specialize TArray): specialize TArray;
var
@@ -133,7 +133,7 @@ function Algo_Unique_Integer(const Arr: TIntegerArray): TIntegerArray;
Bucket: TIntegerArray;
Count: Integer;
end;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaIntegerBuffer;
label
Next;
begin
@@ -164,7 +164,7 @@ function Algo_Unique_Integer(const Arr: TIntegerArray): TIntegerArray;
Next:
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function Algo_Unique_String(const Arr: TStringArray): TStringArray;
@@ -175,7 +175,7 @@ function Algo_Unique_String(const Arr: TStringArray): TStringArray;
Bucket: TStringArray;
Count: Integer;
end;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaStringBuffer;
label
Next;
begin
@@ -206,7 +206,7 @@ function Algo_Unique_String(const Arr: TStringArray): TStringArray;
Next:
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
end.
diff --git a/Source/box.inc b/Source/box.inc
index 2973df6b4..56915c0e3 100644
--- a/Source/box.inc
+++ b/Source/box.inc
@@ -269,7 +269,7 @@ begin
if Contains(Points[I]) then
Buffer.Add(Points[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TBoxHelper.Exclude(Points: TPointArray): TPointArray;
@@ -282,7 +282,7 @@ begin
if not Contains(Points[I]) then
Buffer.Add(Points[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TBoxHelper.NearestEdge(P: TPoint): TPoint;
diff --git a/Source/components/simba.component_tabcontrol.pas b/Source/components/simba.component_tabcontrol.pas
index bcd8a34d5..21424b032 100644
--- a/Source/components/simba.component_tabcontrol.pas
+++ b/Source/components/simba.component_tabcontrol.pas
@@ -119,7 +119,7 @@ TSimbaTabControl = class(TCustomControl)
implementation
uses
- simba.main, simba.mufasatypes, simba.theme, simba.fonthelpers, simba.ide_utils;
+ simba.main, simba.mufasatypes, simba.theme, simba.ide_utils;
function TSimbaTab.GetImageIndex: TImageIndex;
begin
diff --git a/Source/editor/simba.editor.pas b/Source/editor/simba.editor.pas
index fcdc3cde1..23ce5d7fc 100644
--- a/Source/editor/simba.editor.pas
+++ b/Source/editor/simba.editor.pas
@@ -100,7 +100,7 @@ TSimbaEditor = class(TSimbaSynEdit)
implementation
uses
- SynEditPointClasses, SynGutterBase, SynGutter, SynEditMarkupWordGroup, SynHighlighterPas_Simba, SynEditMarkupHighAll,
+ SynEditPointClasses, SynGutterBase, SynGutter, SynHighlighterPas_Simba, SynEditMarkupHighAll,
LazSynEditMouseCmdsTypes, Forms,
simba.fonthelpers, simba.editor_blockcompletion,
simba.editor_docgenerator, simba.editor_commentblock,
@@ -291,8 +291,6 @@ procedure TSimbaEditor.MaybeReplaceModifiers;
end;
procedure TSimbaEditor.SimbaSettingChanged(Setting: TSimbaSetting);
-var
- I: Integer;
begin
case Setting.Name of
'Editor.FontSize':
diff --git a/Source/finders/simba.finder_color.pas b/Source/finders/simba.finder_color.pas
index e173fb60a..c2dd57b9b 100644
--- a/Source/finders/simba.finder_color.pas
+++ b/Source/finders/simba.finder_color.pas
@@ -48,7 +48,7 @@ function MatchColorsOnTarget(Target: TSimbaTarget; Bounds: TBox;
implementation
uses
- simba.overallocatearray, simba.colormath_distance_unrolled, simba.threadpool, simba.atpa, simba.datetime, simba.singlematrix;
+ simba.arraybuffer, simba.colormath_distance_unrolled, simba.threadpool, simba.atpa, simba.singlematrix;
// How much to "Slice" (vertically) the image up for multithreading.
function CalculateSlices(SearchWidth, SearchHeight: Integer): Integer;
@@ -196,7 +196,7 @@ function FindColorsOnBuffer(Formula: EColorSpace; Color: TColor; Tolerance: Sing
PointBuffer.Add(X + OffsetX, Y + OffsetY);
}
{$DEFINE MACRO_FINDCOLORS_END :=
- Result := PointBuffer.Trim();
+ Result := PointBuffer.ToArray(False);
}
MACRO_FINDCOLORS
diff --git a/Source/finders/simba.finder_dtm.pas b/Source/finders/simba.finder_dtm.pas
index efc233ad2..c92863298 100644
--- a/Source/finders/simba.finder_dtm.pas
+++ b/Source/finders/simba.finder_dtm.pas
@@ -39,7 +39,7 @@ function FindDTMRotatedOnTarget(Target: TSimbaTarget;
implementation
uses
- simba.colormath_distance, simba.math, simba.overallocatearray;
+ simba.colormath_distance, simba.arraybuffer;
type
TSearchPoint = record
@@ -178,7 +178,7 @@ function FindDTMOnBuffer(var Limit: TSimpleThreadsafeLimit; DTM: TDTM; Buffer: P
Break;
end;
- Result := PointBuffer.Trim();
+ Result := PointBuffer.ToArray(False);
end;
function FindDTMRotatedOnBuffer(var Limit: TSimpleThreadsafeLimit; Buffer: PColorBGRA; BufferWidth: Integer; SearchWidth, SearchHeight: Integer; DTM: TDTM; StartDegrees, EndDegrees: Double; Step: Double; out FoundDegrees: TDoubleArray; OffsetX, OffsetY: Integer): TPointArray;
@@ -257,7 +257,7 @@ function FindDTMRotatedOnBuffer(var Limit: TSimpleThreadsafeLimit; Buffer: PColo
type
TMatch = record X,Y: Integer; Deg: Double; end;
- TMatchBuffer = specialize TSimbaOverAllocateArray;
+ TMatchBuffer = specialize TSimbaArrayBuffer;
var
I, X, Y: Integer;
MainPointArea: TBox;
diff --git a/Source/finders/simba.finder_image.pas b/Source/finders/simba.finder_image.pas
index 25849796b..84ec663a8 100644
--- a/Source/finders/simba.finder_image.pas
+++ b/Source/finders/simba.finder_image.pas
@@ -37,7 +37,7 @@ function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit;
implementation
uses
- simba.datetime, simba.overallocatearray, simba.threadpool, simba.tpa, simba.atpa;
+ simba.arraybuffer, simba.threadpool, simba.tpa, simba.atpa;
// How much to "Slice" (vertically) the image up for multithreading.
function CalculateSlices(SearchWidth, SearchHeight: Integer): Integer;
@@ -267,7 +267,7 @@ function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit; Image: TSimbaImag
Break;
end;
- Result := PointBuffer.Trim();
+ Result := PointBuffer.ToArray(False);
finally
FreeMem(BitmapColors);
end;
diff --git a/Source/generics.inc b/Source/generics.inc
index b93368ffc..20eb23ead 100644
--- a/Source/generics.inc
+++ b/Source/generics.inc
@@ -134,7 +134,7 @@ end;
generic function IndicesOf<_T>(const Item: _T; const Arr: specialize TArray<_T>): TIntegerArray;
var
I: Integer;
- Res: specialize TSimbaOverAllocateArray;
+ Res: TSimbaIntegerBuffer;
begin
Res.Init(4);
@@ -142,7 +142,7 @@ begin
if (Item = Arr[I]) then
Res.Add(I);
- Result := Res.Trim();
+ Result := Res.ToArray(False);
end;
generic function Mode<_T>(const Arr: specialize TArray<_T>): Integer;
@@ -197,7 +197,7 @@ end;
generic function IndicesOf_SameValue<_T>(const Item: _T; const Arr: specialize TArray<_T>): TIntegerArray;
var
I: Integer;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaIntegerBuffer;
begin
Buffer.Init(4);
@@ -205,6 +205,6 @@ begin
if SameValue(Item, Arr[I]) then
Buffer.Add(I);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
{$ENDIF}
diff --git a/Source/imagebox/simba.imagebox.pas b/Source/imagebox/simba.imagebox.pas
index b5a8f8285..7e9117807 100644
--- a/Source/imagebox/simba.imagebox.pas
+++ b/Source/imagebox/simba.imagebox.pas
@@ -12,7 +12,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, ComCtrls, LCLType,
simba.mufasatypes, simba.image, simba.dtm, simba.imagebox_image,
- simba.colormath, simba.colormath_distance;
+ simba.colormath;
type
TSimbaImageBox_ScrollBox = class(TScrollBox)
diff --git a/Source/imagebox/simba.imagebox_image.pas b/Source/imagebox/simba.imagebox_image.pas
index 87a81e909..de3374c8e 100644
--- a/Source/imagebox/simba.imagebox_image.pas
+++ b/Source/imagebox/simba.imagebox_image.pas
@@ -90,7 +90,7 @@ TSimbaImageBoxBitmap = class(TObject)
implementation
uses
- simba.image_lazbridge, simba.singlematrix, simba.integermatrix;
+ simba.image_lazbridge;
const
HEATMAP_LOOKUP_TABLE: array[0..837] of TColor = (
diff --git a/Source/matchtemplate/simba.matchtemplate_ccoeff.pas b/Source/matchtemplate/simba.matchtemplate_ccoeff.pas
index e356966cc..493493733 100644
--- a/Source/matchtemplate/simba.matchtemplate_ccoeff.pas
+++ b/Source/matchtemplate/simba.matchtemplate_ccoeff.pas
@@ -210,7 +210,7 @@ TSliceCache = record
function TMatchTemplateCache_CCOEFF.GetSliceCache(Lo, Hi: Integer): TSliceCache;
var
- I, Y: Integer;
+ I: Integer;
ImgSlice: TRGBMatrix;
begin
Lock.Enter();
diff --git a/Source/matchtemplate/simba.matchtemplate_ccorr.pas b/Source/matchtemplate/simba.matchtemplate_ccorr.pas
index 3c1a5dc24..1e1cd8a36 100644
--- a/Source/matchtemplate/simba.matchtemplate_ccorr.pas
+++ b/Source/matchtemplate/simba.matchtemplate_ccorr.pas
@@ -43,7 +43,7 @@ implementation
uses
simba.threadpool, simba.simplelock,
- simba.singlematrix, simba.integermatrix;
+ simba.singlematrix;
// MatchTemplate_CCORR
function __MatchTemplate_CCORR(Image, Templ: TIntegerMatrix; Normed: Boolean): TSingleMatrix;
@@ -181,7 +181,7 @@ TSliceCache = record
function TMatchTemplateCache_CCORR.GetSliceCache(Lo, Hi: Integer): TSliceCache;
var
ImgSlice: TRGBMatrix;
- I, Y: Integer;
+ I: Integer;
begin
Lock.Enter();
diff --git a/Source/matchtemplate/simba.matchtemplate_sqdiff.pas b/Source/matchtemplate/simba.matchtemplate_sqdiff.pas
index dea3e8a6d..7b6132986 100644
--- a/Source/matchtemplate/simba.matchtemplate_sqdiff.pas
+++ b/Source/matchtemplate/simba.matchtemplate_sqdiff.pas
@@ -43,7 +43,7 @@ implementation
uses
simba.threadpool, simba.simplelock,
- simba.singlematrix, simba.integermatrix;
+ simba.singlematrix;
// MatchTemplate_SQDIFF
function __MatchTemplate_SQDIFF(Image, Templ: TIntegerMatrix; Normed: Boolean): TSingleMatrix;
@@ -187,7 +187,7 @@ TSliceCache = record
function TMatchTemplateCache_SQDIFF.GetSliceCache(Lo, Hi: Integer): TSliceCache;
var
ImgSlice: TRGBMatrix;
- I, Y: Integer;
+ I: Integer;
begin
Lock.Enter();
diff --git a/Source/package/simba.package_installer.pas b/Source/package/simba.package_installer.pas
index b44c8aa8b..077671578 100644
--- a/Source/package/simba.package_installer.pas
+++ b/Source/package/simba.package_installer.pas
@@ -58,7 +58,7 @@ implementation
uses
Forms, FileUtil,
- simba.mufasatypes, simba.files, simba.threading, simba.env;
+ simba.mufasatypes, simba.threading, simba.env;
function TSimbaPackageInstaller.InternalInstall(URL: String; Path: String; IgnoreList: TStringArray; Flat: Boolean): Boolean;
diff --git a/Source/script/imports/simba/simba.import_pointbuffer.pas b/Source/script/imports/simba/simba.import_pointbuffer.pas
new file mode 100644
index 000000000..ecd9204b3
--- /dev/null
+++ b/Source/script/imports/simba/simba.import_pointbuffer.pas
@@ -0,0 +1,131 @@
+unit simba.import_pointbuffer;
+
+{$i simba.inc}
+
+interface
+
+uses
+ Classes, SysUtils,
+ simba.mufasatypes, simba.script_compiler;
+
+procedure ImportPointBuffer(Compiler: TSimbaScript_Compiler);
+
+implementation
+
+uses
+ Graphics, lptypes, lpvartypes,
+ simba.arraybuffer;
+
+type
+ PSimbaPointBuffer = ^TSimbaPointBuffer;
+
+procedure _LapePointBuffer_Init(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
+begin
+ PSimbaPointBuffer(Params^[0])^.Init(PInteger(Params^[1])^);
+end;
+
+procedure _LapePointBuffer_InitWith(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
+begin
+ PSimbaPointBuffer(Params^[0])^.InitWith(PPointArray(Params^[1])^);
+end;
+
+procedure _LapePointBuffer_Clear(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
+begin
+ PSimbaPointBuffer(Params^[0])^.Clear();
+end;
+
+procedure _LapePointBuffer_Add1(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
+begin
+ PSimbaPointBuffer(Params^[0])^.Add(PPoint(Params^[1])^);
+end;
+
+procedure _LapePointBuffer_Add2(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
+begin
+ PSimbaPointBuffer(Params^[0])^.Add(PInteger(Params^[1])^, PInteger(Params^[2])^);
+end;
+
+procedure _LapePointBuffer_ToArray(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PPointArray(Result)^ := PSimbaPointBuffer(Params^[0])^.ToArray(PBoolean(Params^[1])^);
+end;
+
+procedure _LapePointBuffer_First(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.First();
+end;
+
+procedure _LapePointBuffer_Last(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.Last();
+end;
+
+procedure _LapePointBuffer_Pop(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.Pop();
+end;
+
+procedure _LapePointBuffer_Clear(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PSimbaPointBuffer(Params^[0])^.Clear();
+end;
+
+procedure _LapePointBuffer_Size(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PInteger(Result)^ := PSimbaPointBuffer(Params^[0])^.Size;
+end;
+
+procedure _LapePointBuffer_Count(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PInteger(Result)^ := PSimbaPointBuffer(Params^[0])^.Count;
+end;
+
+procedure _LapePointBuffer_Point(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
+begin
+ PPoint(Result)^ := PSimbaPointBuffer(Params^[0])^.Item[PInteger(Params^[1])^];
+end;
+
+procedure ImportPointBuffer(Compiler: TSimbaScript_Compiler);
+begin
+ with Compiler do
+ begin
+ addGlobalType([
+ 'record',
+ ' {%CODETOOLS OFF}',
+ ' __Length: Integer;',
+ ' __Count: Integer;',
+ ' __Arr: TPointArray;',
+ ' {%CODETOOLS ON}',
+ 'end;'],
+ 'TPointBuffer'
+ );
+ if (getGlobalType('TPointBuffer').Size <> SizeOf(TSimbaPointBuffer)) then
+ SimbaException('SizeOf(TPointBuffer) is wrong');
+
+ addDelayedCode([
+ 'function ToString(constref PointBuffer: TPointBuffer): String; override;',
+ 'begin',
+ ' Result := "TPointBuffer: Size=" + IntToStr(PointBuffer.Size()) + ", Count=" + IntToStr(PointBuffer.Count());',
+ 'end;'
+ ]);
+
+ addGlobalFunc('procedure TPointBuffer.Init(const InitialSize: Integer = 1024);', @_LapePointBuffer_Init);
+ addGlobalFunc('procedure TPointBuffer.InitWith(const Values: TPointArray);', @_LapePointBuffer_InitWith);
+
+ addGlobalFunc('procedure TPointBuffer.Clear;', @_LapePointBuffer_Clear);
+
+ addGlobalFunc('procedure TPointBuffer.Add(Value: TPoint); overload;', @_LapePointBuffer_Add1);
+ addGlobalFunc('procedure TPointBuffer.Add(X, Y: Integer); overload;', @_LapePointBuffer_Add2);
+ addGlobalFunc('function TPointBuffer.ToArray(Copy: Boolean = True): TPointArray;', @_LapePointBuffer_ToArray);
+
+ addGlobalFunc('function TPointBuffer.First: TPoint;', @_LapePointBuffer_First);
+ addGlobalFunc('function TPointBuffer.Last: TPoint;', @_LapePointBuffer_Last);
+ addGlobalFunc('function TPointBuffer.Pop: TPoint;', @_LapePointBuffer_Pop);
+
+ addGlobalFunc('function TPointBuffer.Size: Integer;', @_LapePointBuffer_Size);
+ addGlobalFunc('function TPointBuffer.Count: Integer;', @_LapePointBuffer_Count);
+ addGlobalFunc('function TPointBuffer.Point(Index: Integer): TPoint;', @_LapePointBuffer_Point);
+ end;
+end;
+
+end.
+
diff --git a/Source/script/imports/simba/simba.import_tpa.pas b/Source/script/imports/simba/simba.import_tpa.pas
index 0af12ca3d..ab95fe498 100644
--- a/Source/script/imports/simba/simba.import_tpa.pas
+++ b/Source/script/imports/simba/simba.import_tpa.pas
@@ -19,7 +19,7 @@ implementation
uses
lptypes,
- simba.tpa, simba.circle, simba.geometry,
+ simba.tpa, simba.geometry,
simba.algo_difference, simba.algo_intersection, simba.algo_symmetricDifference;
(*
diff --git a/Source/script/imports/simbaclasses/simba.import_class_image.pas b/Source/script/imports/simbaclasses/simba.import_class_image.pas
index 833e71bb0..76f6ac6bb 100644
--- a/Source/script/imports/simbaclasses/simba.import_class_image.pas
+++ b/Source/script/imports/simbaclasses/simba.import_class_image.pas
@@ -15,7 +15,7 @@ implementation
uses
Graphics,
lptypes,
- simba.image, simba.circle;
+ simba.image;
type
PBitmap = ^TBitmap;
diff --git a/Source/script/imports/simbaclasses/simba.import_externalimage.pas b/Source/script/imports/simbaclasses/simba.import_externalimage.pas
index ab1ff928c..4bedfd9d7 100644
--- a/Source/script/imports/simbaclasses/simba.import_externalimage.pas
+++ b/Source/script/imports/simbaclasses/simba.import_externalimage.pas
@@ -14,7 +14,7 @@ implementation
uses
lptypes,
- simba.image, simba.externalimage, simba.circle;
+ simba.image, simba.externalimage;
procedure _LapeExternalImage_Create(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
begin
diff --git a/Source/script/simba.script_imports.pas b/Source/script/simba.script_imports.pas
index e071f33fb..e48aaafb0 100644
--- a/Source/script/simba.script_imports.pas
+++ b/Source/script/simba.script_imports.pas
@@ -39,7 +39,8 @@ implementation
simba.import_math, simba.import_misc, simba.import_input,
simba.import_script, simba.import_slacktree, simba.import_string,
simba.import_variant, simba.import_random,
- simba.import_debugimage, simba.import_web, simba.import_dialogs, simba.import_threading;
+ simba.import_debugimage, simba.import_web, simba.import_dialogs, simba.import_threading,
+ simba.import_pointbuffer;
procedure AddSimbaImports(Compiler: TSimbaScript_Compiler);
begin
@@ -91,6 +92,7 @@ procedure AddSimbaImports(Compiler: TSimbaScript_Compiler);
ImportWeb(Compiler);
ImportDialogs(Compiler);
ImportThreading(Compiler);
+ ImportPointBuffer(Compiler);
end;
end.
diff --git a/Source/script/simba.script_pluginmethods.pas b/Source/script/simba.script_pluginmethods.pas
index 288ddcf50..d53a00861 100644
--- a/Source/script/simba.script_pluginmethods.pas
+++ b/Source/script/simba.script_pluginmethods.pas
@@ -62,7 +62,7 @@ interface
implementation
uses
- lpvartypes, lpvartypes_record, lpvartypes_array, lpffiwrappers;
+ lpvartypes, lpvartypes_record, lpvartypes_array;
// Sync wrapper which includes a data parameter
type
diff --git a/Source/script/simba.scriptthread.pas b/Source/script/simba.scriptthread.pas
index 33ac52fc8..9c6c407c5 100644
--- a/Source/script/simba.scriptthread.pas
+++ b/Source/script/simba.scriptthread.pas
@@ -74,7 +74,7 @@ procedure TSimbaScriptRunner.DoInputThread;
State: ESimbaScriptState;
begin
Stream := THandleStream.Create(StdInputHandle);
- while Stream.Read(State, SizeOf(ESimbaScriptState)) = SizeOf(ESimbaScriptState) do
+ while Stream.Read(State{%H-}, SizeOf(ESimbaScriptState)) = SizeOf(ESimbaScriptState) do
FScript.State := State;
Stream.Free();
end;
diff --git a/Source/simba.overallocatearray.pas b/Source/simba.arraybuffer.pas
similarity index 64%
rename from Source/simba.overallocatearray.pas
rename to Source/simba.arraybuffer.pas
index 27e50c912..8005a1e7b 100644
--- a/Source/simba.overallocatearray.pas
+++ b/Source/simba.arraybuffer.pas
@@ -2,10 +2,11 @@
Author: Raymond van Venetiƫ and Merlijn Wajer
Project: Simba (https://github.com/MerlijnWajer/Simba)
License: GNU General Public License (https://www.gnu.org/licenses/gpl-3.0)
+
+ Overallocate array.
}
-unit simba.overallocatearray;
+unit simba.arraybuffer;
-{$DEFINE SIMBA_MAX_OPTIMIZATION}
{$i simba.inc}
interface
@@ -15,10 +16,10 @@ interface
simba.mufasatypes;
type
- generic TSimbaOverAllocateArray<_T> = record
+ generic TSimbaArrayBuffer<_T> = record
private
type
- TSelf = specialize TSimbaOverAllocateArray<_T>;
+ TSelf = specialize TSimbaArrayBuffer<_T>;
TArr = specialize TArray<_T>;
private
FLength: Integer;
@@ -28,6 +29,7 @@ generic TSimbaOverAllocateArray<_T> = record
procedure EnsureGrowth(const Len: Integer = 1); inline;
function GetItem(const Index: Integer): _T; inline;
public
+ property Size: Integer read FLength;
property Count: Integer read FCount;
property Item[Index: Integer]: _T read GetItem; default;
@@ -42,17 +44,16 @@ generic TSimbaOverAllocateArray<_T> = record
function Last: _T; inline;
function Pop: _T; inline;
- function Trim: TArr;
- function Copy: TArr;
+ function ToArray(Copy: Boolean = True): TArr;
class operator Initialize(var Self: TSelf);
end;
- TSimbaStringBuffer = specialize TSimbaOverAllocateArray;
- TSimbaPointBuffer = specialize TSimbaOverAllocateArray;
- TSimbaPointArrayBuffer = specialize TSimbaOverAllocateArray;
+ TSimbaIntegerBuffer = specialize TSimbaArrayBuffer;
+ TSimbaStringBuffer = specialize TSimbaArrayBuffer;
+ TSimbaPointBuffer = specialize TSimbaArrayBuffer;
+ TSimbaPointArrayBuffer = specialize TSimbaArrayBuffer;
-type
TSimbaPointBufferHelper = record helper for TSimbaPointBuffer
public
procedure Add(const X, Y: Integer); overload; inline;
@@ -60,7 +61,7 @@ TSimbaPointBufferHelper = record helper for TSimbaPointBuffer
implementation
-procedure TSimbaOverAllocateArray.EnsureGrowth(const Len: Integer);
+procedure TSimbaArrayBuffer.EnsureGrowth(const Len: Integer);
begin
if (FCount + Len >= FLength) then
begin
@@ -87,17 +88,17 @@ procedure TSimbaPointBufferHelper.Add(const X, Y: Integer);
Inc(FCount);
end;
-function TSimbaOverAllocateArray.GetItem(const Index: Integer): _T;
+function TSimbaArrayBuffer.GetItem(const Index: Integer): _T;
begin
Result := FArr[Index];
end;
-procedure TSimbaOverAllocateArray.Clear;
+procedure TSimbaArrayBuffer.Clear;
begin
FCount := 0;
end;
-procedure TSimbaOverAllocateArray.Init(const InitialSize: Integer);
+procedure TSimbaArrayBuffer.Init(const InitialSize: Integer);
begin
FLength := InitialSize;
FCount := 0;
@@ -106,14 +107,14 @@ procedure TSimbaOverAllocateArray.Init(const InitialSize: Integer);
SetLength(FArr, FLength);
end;
-procedure TSimbaOverAllocateArray.InitWith(const Values: TArr);
+procedure TSimbaArrayBuffer.InitWith(const Values: TArr);
begin
FArr := Values;
FLength := Length(FArr);
FCount := FLength;
end;
-procedure TSimbaOverAllocateArray.Add(const Value: _T);
+procedure TSimbaArrayBuffer.Add(const Value: _T);
begin
EnsureGrowth();
@@ -121,7 +122,7 @@ procedure TSimbaOverAllocateArray.Add(const Value: _T);
Inc(FCount);
end;
-procedure TSimbaOverAllocateArray.Add(const Values: TArr);
+procedure TSimbaArrayBuffer.Add(const Values: TArr);
var
Len: Integer;
begin
@@ -135,36 +136,36 @@ procedure TSimbaOverAllocateArray.Add(const Values: TArr);
end;
end;
-function TSimbaOverAllocateArray.First: _T;
+function TSimbaArrayBuffer.First: _T;
begin
Result := FArr[0];
end;
-function TSimbaOverAllocateArray.Last: _T;
+function TSimbaArrayBuffer.Last: _T;
begin
Result := FArr[FCount - 1];
end;
-function TSimbaOverAllocateArray.Pop: _T;
+function TSimbaArrayBuffer.Pop: _T;
begin
Result := FArr[FCount - 1];
Dec(FCount);
end;
-function TSimbaOverAllocateArray.Trim: TArr;
+function TSimbaArrayBuffer.ToArray(Copy: Boolean): TArr;
begin
- FLength := FCount;
- SetLength(FArr, FLength);
-
- Result := FArr;
-end;
+ if Copy then
+ Result := System.Copy(FArr, 0, FCount)
+ else
+ begin
+ FLength := FCount;
+ SetLength(FArr, FLength);
-function TSimbaOverAllocateArray.Copy: TArr;
-begin
- Result := System.Copy(FArr, 0, FCount);
+ Result := FArr;
+ end;
end;
-class operator TSimbaOverAllocateArray.Initialize(var Self: TSelf);
+class operator TSimbaArrayBuffer.Initialize(var Self: TSelf);
begin
Self := Default(TSelf);
end;
diff --git a/Source/simba.atpa.pas b/Source/simba.atpa.pas
index e58b33705..eba2b3009 100644
--- a/Source/simba.atpa.pas
+++ b/Source/simba.atpa.pas
@@ -63,7 +63,7 @@ interface
implementation
uses
- simba.tpa, simba.algo_sort, simba.overallocatearray, simba.integermatrix, simba.quad;
+ simba.tpa, simba.algo_sort, simba.arraybuffer, simba.quad;
function T2DPointArrayHelper.Sort(Weights: TIntegerArray; LowToHigh: Boolean): T2DPointArray;
var
@@ -290,7 +290,7 @@ function T2DPointArrayHelper.ExcludeSize(Len: Integer; KeepIf: EComparator): T2D
__NE__: if (Length(Self[I]) <> Len) then Buffer.Add(Copy(Self[I]));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function T2DPointArrayHelper.ExcludeSize(MinLen, MaxLen: Integer): T2DPointArray;
@@ -304,7 +304,7 @@ function T2DPointArrayHelper.ExcludeSize(MinLen, MaxLen: Integer): T2DPointArray
if InRange(Length(Self[I]), MinLen, MaxLen) then
Buffer.Add(Copy(Self[I]));
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);;
end;
function T2DPointArrayHelper.ExcludeSizeEx(MaxLen: Integer): T2DPointArray;
@@ -324,7 +324,7 @@ function T2DPointArrayHelper.ExcludeDimensions(MinShortSide, MinLongSide, MaxSho
if InRange(ShortSideLen, MinShortSide, MaxShortSide) and InRange(LongSideLen, MinLongSide, MaxLongSide) then
Buffer.Add(Copy(Self[I]));
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);;
end;
function T2DPointArrayHelper.ExcludeDimensionsEx(MinShortSide, MinLongSide: Integer): T2DPointArray;
@@ -447,7 +447,7 @@ function T2DPointArrayHelper.Intersection: TPointArray;
end;
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);;
end;
diff --git a/Source/simba.circle.pas b/Source/simba.circle.pas
index 16efa7320..11ae51df5 100644
--- a/Source/simba.circle.pas
+++ b/Source/simba.circle.pas
@@ -43,7 +43,7 @@ implementation
uses
Math,
- simba.math, simba.tpa, simba.random, simba.overallocatearray, simba.geometry;
+ simba.math, simba.tpa, simba.random, simba.arraybuffer, simba.geometry;
class function TCircleHelper.Create(AX, AY: Integer; ARadius: Integer): TCircle;
begin
@@ -117,7 +117,7 @@ function TCircleHelper.Extract(Points: TPointArray): TPointArray;
if Contains(Points[I]) then
Buffer.Add(Points[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TCircleHelper.Exclude(Points: TPointArray): TPointArray;
@@ -130,7 +130,7 @@ function TCircleHelper.Exclude(Points: TPointArray): TPointArray;
if not Contains(Points[I]) then
Buffer.Add(Points[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TCircleHelper.RandomPoint: TPoint;
diff --git a/Source/simba.externalimage.pas b/Source/simba.externalimage.pas
index aa86a1181..ffe91bfaf 100644
--- a/Source/simba.externalimage.pas
+++ b/Source/simba.externalimage.pas
@@ -6,8 +6,7 @@ interface
uses
Classes, SysUtils, Graphics,
- simba.mufasatypes, simba.baseclass, simba.image, simba.simplelock,
- simba.circle;
+ simba.mufasatypes, simba.baseclass, simba.image, simba.simplelock;
type
TSimbaExternalImageCallback = procedure(Image: Pointer); cdecl;
diff --git a/Source/simba.files.pas b/Source/simba.files.pas
index ac1f5910d..c3833424e 100644
--- a/Source/simba.files.pas
+++ b/Source/simba.files.pas
@@ -108,7 +108,7 @@ implementation
BaseUnix,
{$ENDIF}
FileUtil, LazFileUtils, Zipper, IniFiles, md5, sha1,
- simba.encoding, simba.overallocatearray;
+ simba.encoding, simba.arraybuffer;
class function TSimbaDir.DirList(Path: String; Recursive: Boolean): TStringArray;
var
@@ -137,7 +137,7 @@ class function TSimbaDir.DirList(Path: String; Recursive: Boolean): TStringArray
begin
Get(Path);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
class function TSimbaDir.DirListFiles(Path: String; Recursive: Boolean): TStringArray;
@@ -168,7 +168,7 @@ class function TSimbaDir.DirListFiles(Path: String; Recursive: Boolean): TString
begin
Get(Path);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
class function TSimbaDir.DirSearch(Path: String; Mask: String; Recursive: Boolean): TStringArray;
diff --git a/Source/simba.finder.pas b/Source/simba.finder.pas
index 472f66584..5ca0b8dd2 100644
--- a/Source/simba.finder.pas
+++ b/Source/simba.finder.pas
@@ -79,7 +79,7 @@ TColorTolerance = record
implementation
uses
- simba.overallocatearray, simba.singlematrix, simba.tpa, simba.matchtemplate,
+ simba.arraybuffer, simba.singlematrix, simba.tpa, simba.matchtemplate,
simba.finder_color, simba.finder_image, simba.finder_dtm;
function TSimbaFinder.GetDataAsBitmap(var Bounds: TBox; out Bitmap: TSimbaImage): Boolean;
@@ -440,7 +440,7 @@ function TSimbaFinder.FindEdges(MinDiff: Single; ColorSpace: EColorSpace; Multip
Bitmap.Free();
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TSimbaFinder.FindEdges(MinDiff: Single; Bounds: TBox): TPointArray;
diff --git a/Source/simba.image.pas b/Source/simba.image.pas
index d4cd7bfea..90ffb19e1 100644
--- a/Source/simba.image.pas
+++ b/Source/simba.image.pas
@@ -222,8 +222,8 @@ implementation
uses
Math, FPImage, BMPcomn, fpqoi_simba,
- simba.overallocatearray, simba.geometry, simba.tpa,
- simba.encoding, simba.compress, simba.math,
+ simba.arraybuffer, simba.geometry, simba.tpa,
+ simba.encoding, simba.compress,
simba.nativeinterface, simba.singlematrix,
simba.image_lazbridge, simba.rgbsumtable;
@@ -733,7 +733,7 @@ function TSimbaImage.PixelDifferenceTPA(Other: TSimbaImage): TPointArray;
var
X, Y, W, H: Integer;
Index: Integer;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaPointBuffer;
begin
if (FWidth <> Other.Width) or (FHeight <> Other.Height) then
SimbaException('TSimbaImage.PixelDifference: Both images must be equal dimensions');
@@ -750,14 +750,14 @@ function TSimbaImage.PixelDifferenceTPA(Other: TSimbaImage): TPointArray;
Buffer.Add(TPoint.Create(X, Y));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TSimbaImage.PixelDifferenceTPA(Other: TSimbaImage; Tolerance: Single): TPointArray;
var
X, Y, W, H: Integer;
Index: Integer;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaPointBuffer;
begin
if (FWidth <> Other.Width) or (FHeight <> Other.Height) then
SimbaException('TSimbaImage.PixelDifference: Both images must be equal dimensions');
@@ -779,7 +779,7 @@ function TSimbaImage.PixelDifferenceTPA(Other: TSimbaImage; Tolerance: Single):
Buffer.Add(TPoint.Create(X, Y));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
procedure TSimbaImage.LoadFromLazBitmap(LazBitmap: TBitmap);
diff --git a/Source/simba.integermatrix.pas b/Source/simba.integermatrix.pas
index e1cf1bbec..1cee23fa3 100644
--- a/Source/simba.integermatrix.pas
+++ b/Source/simba.integermatrix.pas
@@ -26,7 +26,7 @@ interface
implementation
uses
- simba.math, simba.overallocatearray;
+ simba.math, simba.arraybuffer;
function TIntegerMatrixHelper.Copy: TIntegerMatrix;
var
@@ -130,7 +130,7 @@ function TIntegerMatrixHelper.Flatten: TIntegerArray;
function TIntegerMatrixHelper.Indices(Value: Integer; Comparator: EComparator): TPointArray;
var
W, H, X, Y: Integer;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaPointBuffer;
begin
W := Self.Width - 1;
H := Self.Height - 1;
@@ -147,7 +147,7 @@ function TIntegerMatrixHelper.Indices(Value: Integer; Comparator: EComparator):
__NE__: if Self[Y, X] <> Value then Buffer.Add(TPoint.Create(X, Y));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
end.
diff --git a/Source/simba.ipc.pas b/Source/simba.ipc.pas
index 5d06874b6..e24ceb97e 100644
--- a/Source/simba.ipc.pas
+++ b/Source/simba.ipc.pas
@@ -90,7 +90,7 @@ procedure TSimbaIPCServer.Execute;
Result := TMemoryStream.Create();
try
- while (FInputStream.Read(Header, SizeOf(TSimbaIPCHeader)) = SizeOf(TSimbaIPCHeader)) and (not TThread.CheckTerminated) do
+ while (FInputStream.Read(Header{%H-}, SizeOf(TSimbaIPCHeader)) = SizeOf(TSimbaIPCHeader)) and (not TThread.CheckTerminated) do
begin
// Keep a small amount of memory (0.25 mb) if allocated
Params.Position := 0;
diff --git a/Source/simba.mufasatypes.pas b/Source/simba.mufasatypes.pas
index 56878883b..d322bf573 100644
--- a/Source/simba.mufasatypes.pas
+++ b/Source/simba.mufasatypes.pas
@@ -424,7 +424,7 @@ implementation
uses
math, forms, uregexpr, strutils, jsonparser, jsonscanner,
- simba.math, simba.overallocatearray, simba.geometry,
+ simba.arraybuffer, simba.geometry,
simba.algo_sort, simba.random;
{$DEFINE BODY}
diff --git a/Source/simba.openssl.pas b/Source/simba.openssl.pas
index 44d44759d..83d1fb9a1 100644
--- a/Source/simba.openssl.pas
+++ b/Source/simba.openssl.pas
@@ -43,7 +43,7 @@ function ExtractLib(Stream: TStream; FileName: String): String;
OutputStream := TFileStream.Create(FileName, fmCreate or fmOpenWrite or fmShareDenyWrite);
repeat
- Count := InputStream.Read(Buffer[1], Length(Buffer));
+ Count := InputStream.Read({%H-}Buffer[1], Length(Buffer));
until OutputStream.Write(Buffer[1], Count) = 0;
InputStream.Free();
diff --git a/Source/simba.quad.pas b/Source/simba.quad.pas
index c128da766..8494fe286 100644
--- a/Source/simba.quad.pas
+++ b/Source/simba.quad.pas
@@ -49,7 +49,7 @@ implementation
uses
Math,
- simba.math, simba.tpa, simba.random, simba.geometry, simba.overallocatearray;
+ simba.math, simba.tpa, simba.random, simba.geometry, simba.arraybuffer;
class function TQuadHelper.Create(ATop, ARight, ABottom, ALeft: TPoint): TQuad;
begin
@@ -187,7 +187,7 @@ function TQuadHelper.Extract(Points: TPointArray): TPointArray;
if Contains(Points[I]) then
Buffer.Add(Points[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TQuadHelper.Exclude(Points: TPointArray): TPointArray;
@@ -200,7 +200,7 @@ function TQuadHelper.Exclude(Points: TPointArray): TPointArray;
if not Contains(Points[I]) then
Buffer.Add(Points[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TQuadHelper.Expand(Amount: Double): TQuad;
diff --git a/Source/simba.singlematrix.pas b/Source/simba.singlematrix.pas
index c0a0ba9f1..960292eea 100644
--- a/Source/simba.singlematrix.pas
+++ b/Source/simba.singlematrix.pas
@@ -79,7 +79,7 @@ implementation
uses
Math,
- simba.math, simba.overallocatearray, simba.heaparray, simba.tpa;
+ simba.math, simba.arraybuffer, simba.heaparray, simba.tpa;
class operator TSingleSum.:=(const Right: Single): TSingleSum;
begin
@@ -360,7 +360,7 @@ function TSingleMatrixHelper.ArgMax: TPoint;
for X := 0 to W do
begin
Value := Self[Y, X];
- if (not IsNumber(Value)) or (HasValue and (Value <= Best)) then
+ if (not IsNumber(Value)) or (HasValue and (Value <= {%H-}Best)) then
Continue;
HasValue := True;
@@ -387,7 +387,7 @@ function TSingleMatrixHelper.ArgMin: TPoint;
for X := 0 to W do
begin
Value := Self[Y, X];
- if (not IsNumber(Value)) or (HasValue and (Value >= Best)) then
+ if (not IsNumber(Value)) or (HasValue and (Value >= {%H-}Best)) then
Continue;
HasValue := True;
@@ -424,7 +424,7 @@ function TSingleMatrixHelper.NormMinMax(Alpha, Beta: Single): TSingleMatrix;
function TSingleMatrixHelper.Indices(Value: Single; Comparator: EComparator): TPointArray;
var
W, H, X, Y: Integer;
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaPointBuffer;
begin
W := Self.Width - 1;
H := Self.Height - 1;
@@ -441,7 +441,7 @@ function TSingleMatrixHelper.Indices(Value: Single; Comparator: EComparator): TP
__NE__: if Self[Y, X] <> Value then Buffer.Add(TPoint.Create(X, Y));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TSingleMatrixHelper.ArgMulti(Count: Integer; HiLo: Boolean): TPointArray;
@@ -639,7 +639,7 @@ function TSingleMatrixHelper.ArgExtrema(Count: Int32; HiLo: Boolean = True): TPo
end;
end;
- Result := Buffer.Copy();
+ Result := Buffer.ToArray();
end;
function pass_y(): TPointArray;
@@ -659,7 +659,7 @@ function TSingleMatrixHelper.ArgExtrema(Count: Int32; HiLo: Boolean = True): TPo
end;
end;
- Result := Buffer.Copy();
+ Result := Buffer.ToArray();
end;
var
diff --git a/Source/simba.tpa.pas b/Source/simba.tpa.pas
index 5ac873c51..349ae1ce6 100644
--- a/Source/simba.tpa.pas
+++ b/Source/simba.tpa.pas
@@ -141,10 +141,9 @@ interface
implementation
uses
- math,
- simba.overallocatearray, simba.geometry, simba.math,
- simba.algo_sort, simba.algo_intersection, simba.slacktree, simba.algo_unique,
- simba.singlematrix, simba.integermatrix;
+ Math,
+ simba.arraybuffer, simba.geometry, simba.math,
+ simba.algo_sort, simba.algo_intersection, simba.slacktree, simba.algo_unique;
procedure GetAdjacent4(var Adj: TPointArray; const P: TPoint); inline;
begin
@@ -239,7 +238,7 @@ class function TPointArrayHelper.CreateFromCircle(Center: TPoint; Radius: Intege
for x := B.X1 to B.X2 do
if Sqr(X - Center.X) + Sqr(Y - Center.Y) < d then
Buffer.Add(X, Y);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
begin
@@ -318,7 +317,7 @@ class function TPointArrayHelper.CreateFromEllipse(Center: TPoint; RadiusX, Radi
end;
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
procedure CreateFilled;
@@ -339,7 +338,7 @@ class function TPointArrayHelper.CreateFromEllipse(Center: TPoint; RadiusX, Radi
for x:= B.X1 to B.X2 do
if (Sqr(X - Center.X) * SqY) + (Sqr(Y - Center.Y) * SqX) < d then
Buffer.Add(X, Y);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
begin
@@ -489,7 +488,7 @@ function TPointArrayHelper.Invert(ABounds: TBox): TPointArray;
if not Matrix[Y, X] then
Buffer.Add(ABounds.X1 + X, ABounds.Y1 + Y);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.Invert: TPointArray;
@@ -511,7 +510,7 @@ function TPointArrayHelper.Connect: TPointArray;
Buffer.Add(TPointArray.CreateFromLine(Self[High(Self)], Self[0]));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.Density: Double;
@@ -554,7 +553,7 @@ function TPointArrayHelper.Edges: TPointArray;
Buffer.Add(Self[I]);
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.Border: TPointArray;
@@ -642,7 +641,7 @@ function TPointArrayHelper.Border: TPointArray;
end;
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.Skeleton(FMin: Integer; FMax: Integer): TPointArray;
@@ -756,8 +755,8 @@ function TPointArrayHelper.FloodFill(const StartPoint: TPoint; const EightWay: B
B: TBox;
Width, Height: Integer;
Checked: TBooleanMatrix;
- Queue: specialize TSimbaOverAllocateArray;
- Arr: specialize TSimbaOverAllocateArray;
+ Queue: TSimbaPointBuffer;
+ Arr: TSimbaPointBuffer;
procedure Push(const X, Y: Integer); inline;
begin
@@ -807,7 +806,7 @@ function TPointArrayHelper.FloodFill(const StartPoint: TPoint; const EightWay: B
while (Queue.Count > 0) do
CheckNeighbours(Queue.Pop());
- Result := Arr.Trim();
+ Result := Arr.ToArray(False);
end;
function TPointArrayHelper.ShapeFill: TPointArray;
@@ -834,7 +833,7 @@ function TPointArrayHelper.ShapeFill: TPointArray;
if TSimbaGeometry.PointInPolygon((Row[I-1] + Row[I]) div 2, Self) then
HorzLine(Row[0].Y, Row[I-1].X, Row[I].X);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
procedure TPointArrayHelper.FurthestPoints(out A, B: TPoint);
@@ -1104,7 +1103,7 @@ function TPointArrayHelper.Erode(Iterations: Integer): TPointArray;
for X := 0 to B.X2-1 do
if Matrix[Y, X] then
QueueA.Add(X + B.X1, Y + B.Y1);
- Result := QueueA.Trim();
+ Result := QueueA.ToArray(False);
end;
function TPointArrayHelper.Grow(Iterations: Integer): TPointArray;
@@ -1174,7 +1173,7 @@ function TPointArrayHelper.Grow(Iterations: Integer): TPointArray;
for X := 0 to B.X2-1 do
if Matrix[Y, X] then
QueueA.Add(X + B.X1, Y + B.Y1);
- Result := QueueA.Trim();
+ Result := QueueA.ToArray(False);
end;
function TPointArrayHelper.Unique: TPointArray;
@@ -1214,7 +1213,7 @@ function TPointArrayHelper.ReduceByDistance(Dist: Integer): TPointArray;
end;
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.ExcludeDist(Center: TPoint; MinDist, MaxDist: Double): TPointArray;
@@ -1234,7 +1233,7 @@ function TPointArrayHelper.ExcludeDist(Center: TPoint; MinDist, MaxDist: Double)
Buffer.Add(Self[I]);
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.ExcludePolygon(Polygon: TPointArray): TPointArray;
@@ -1247,7 +1246,7 @@ function TPointArrayHelper.ExcludePolygon(Polygon: TPointArray): TPointArray;
if not Self[I].InPolygon(Polygon) then
Buffer.Add(Self[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.ExcludeBox(Box: TBox): TPointArray;
@@ -1289,7 +1288,7 @@ function TPointArrayHelper.ExcludePoints(Points: TPointArray): TPointArray;
if not Matrix[Self[I].Y - B.Y1, Self[I].X - B.X1] then
Buffer.Add(Self[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.ExtractDist(Center: TPoint; MinDist, MaxDist: Single): TPointArray;
@@ -1309,7 +1308,7 @@ function TPointArrayHelper.ExtractDist(Center: TPoint; MinDist, MaxDist: Single)
Buffer.Add(Self[I]);
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.ExtractPolygon(Polygon: TPointArray): TPointArray;
@@ -1322,7 +1321,7 @@ function TPointArrayHelper.ExtractPolygon(Polygon: TPointArray): TPointArray;
if Self[I].InPolygon(Polygon) then
Buffer.Add(Self[I]);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.ExtractBox(Box: TBox): TPointArray;
@@ -1377,7 +1376,7 @@ function TPointArrayHelper.ExtractPie(StartDegree, EndDegree, MinRadius, MaxRadi
Buffer.Add(Self[I]);
end;
- Result := TPointArray(Buffer.Trim()).ExtractDist(Center, MinRadius, MaxRadius);
+ Result := TPointArray(Buffer.ToArray(False)).ExtractDist(Center, MinRadius, MaxRadius);
end else
Result := Self.ExtractDist(Center, MinRadius, MaxRadius);
end;
@@ -1464,7 +1463,7 @@ function TPointArrayHelper.RotateEx(Radians: Double): TPointArray;
end;
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.PointsNearby(Other: TPointArray; MinDist, MaxDist: Double): TPointArray;
@@ -1482,7 +1481,7 @@ function TPointArrayHelper.PointsNearby(Other: TPointArray; MinDist, MaxDist: Do
Buffer.Add(Tree.RangeQueryEx(Other[I], MinDist, MinDist, MaxDist, MaxDist, True));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.PointsNearby(Other: TPointArray; MinDistX, MinDistY, MaxDistX, MaxDistY: Double): TPointArray;
@@ -1500,7 +1499,7 @@ function TPointArrayHelper.PointsNearby(Other: TPointArray; MinDistX, MinDistY,
Buffer.Add(Tree.RangeQueryEx(Other[I], MinDistX, MinDistY, MaxDistX, MaxDistY, True));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.IsPointNearby(Other: TPoint; MinDist, MaxDist: Double): Boolean;
@@ -1663,7 +1662,7 @@ function TPointArrayHelper.Rows: T2DPointArray;
Buffer.Add(Copy(TPA, Start, I-Start));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.Columns: T2DPointArray;
@@ -1686,7 +1685,7 @@ function TPointArrayHelper.Columns: T2DPointArray;
Buffer.Add(Copy(TPA, Start, I-Start));
end;
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
end;
function TPointArrayHelper.Split(Dist: Integer): T2DPointArray;
@@ -1713,7 +1712,7 @@ function TPointArrayHelper.Split(Dist: Integer): T2DPointArray;
while ((Hi - ec) >= 0) do
begin
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
Buffer.Clear();
Buffer.Add(TPA[0]);
@@ -1741,9 +1740,9 @@ function TPointArrayHelper.Split(Dist: Integer): T2DPointArray;
end;
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
- Result := ResultBuffer.Trim();
+ Result := ResultBuffer.ToArray(False);
end;
end;
@@ -1770,7 +1769,7 @@ function TPointArrayHelper.Split(DistX, DistY: Integer): T2DPointArray;
while ((Hi - ec) >= 0) do
begin
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
Buffer.Clear();
Buffer.Add(TPA[0]);
@@ -1798,9 +1797,9 @@ function TPointArrayHelper.Split(DistX, DistY: Integer): T2DPointArray;
end;
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
- Result := ResultBuffer.Trim();
+ Result := ResultBuffer.ToArray(False);
end;
end;
@@ -1856,7 +1855,7 @@ TPointScan = record
if PointScan[TPA[I].Y, TPA[I].X].HasPoints then
begin
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
Buffer.Clear();
Buffer.Add(TPA[I].X + OffsetX, TPA[I].Y + OffsetY);
@@ -1904,9 +1903,9 @@ TPointScan = record
end;
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
- Result := ResultBuffer.Trim();
+ Result := ResultBuffer.ToArray(False);
end;
end;
@@ -1960,7 +1959,7 @@ TPointScan = record
if PointScan[TPA[I].Y, TPA[I].X].HasPoints then
begin
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
Buffer.Clear();
Buffer.Add(TPA[I].X + OffsetX, TPA[I].Y + OffsetY);
@@ -2000,9 +1999,9 @@ TPointScan = record
end;
if (Buffer.Count > 0) then
- ResultBuffer.Add(Buffer.Copy());
+ ResultBuffer.Add(Buffer.ToArray());
- Result := ResultBuffer.Trim();
+ Result := ResultBuffer.ToArray(False);
end;
end;
@@ -2057,7 +2056,7 @@ TScan = record
SetLength(Result, ScanCount);
for I := 0 to ScanCount - 1 do
- Result[I] := Scans[I].Arr.Trim();
+ Result[I] := Scans[I].Arr.ToArray(False);
end;
end;
@@ -2114,7 +2113,7 @@ TScan = record
SetLength(Result, ScanCount);
for I := 0 to ScanCount - 1 do
- Result[I] := Scans[I].Arr.Trim();
+ Result[I] := Scans[I].Arr.ToArray(False);
end;
end;
@@ -2154,7 +2153,7 @@ function TPointArrayHelper.PartitionEx(StartPoint: TPoint; BoxWidth, BoxHeight:
for I := 0 to High(Result) do
if (Buffers[I].Count > 0) then
begin
- Result[ResultCount] := Buffers[I].Trim();
+ Result[ResultCount] := Buffers[I].ToArray(False);
Inc(ResultCount);
end;
SetLength(Result, ResultCount);
diff --git a/Source/string.inc b/Source/string.inc
index 9e9537bf6..6705bf1fd 100644
--- a/Source/string.inc
+++ b/Source/string.inc
@@ -422,7 +422,7 @@ end;
function TSimbaStringHelper.IndicesOf(const Value: String): TIntegerArray;
var
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaIntegerBuffer;
Matches: SizeIntArray;
I: Integer;
begin
@@ -438,7 +438,7 @@ begin
if (Self[I] = Value) then
Buffer.Add(I);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
Exit;
end;
@@ -452,7 +452,7 @@ end;
function TSimbaStringHelper.IndicesOf(const Value: String; Offset: Integer): TIntegerArray;
var
- Buffer: specialize TSimbaOverAllocateArray;
+ Buffer: TSimbaIntegerBuffer;
Matches: SizeIntArray;
I: Integer;
begin
@@ -468,7 +468,7 @@ begin
if (Self[I] = Value) then
Buffer.Add(I);
- Result := Buffer.Trim();
+ Result := Buffer.ToArray(False);
Exit;
end;
diff --git a/Third-Party/fpqoi_simba.pas b/Third-Party/fpqoi_simba.pas
index 3817de0da..713c84162 100644
--- a/Third-Party/fpqoi_simba.pas
+++ b/Third-Party/fpqoi_simba.pas
@@ -135,7 +135,7 @@ procedure TFPReaderQoi.InternalRead (Stream:TStream; Img:TFPCustomImage);
arr : array [0..63] of TQoiPixel;
iA : DWord; {index in pixel array}
- p, aQ : pbyte; orgSize, imgSize : qword;
+ p: pbyte; orgSize, imgSize : qword;
Row, Col, w, h : DWord;
aLine : pbyte;