Jump to content
Alex7691

Tiny.Library issues

Recommended Posts

Has anyone had any luck with Tiny.Library (https://github.com/d-mozulyov/Tiny.Library), more specifically with its Generic classes?

BTW, Rapid.Generics contains an older/simpler version of its Tiny.Generics unit (https://github.com/d-mozulyov/Rapid.Generics)

 

I did a quick test on a TDictionary and the performance is impressive compared to the standard System.Generics. Collections dictionary.

However, some other tests with TList<> , for example, showed random errors that were difficult to identify the cause, such as exceptions in ReallocMem().

In addition, I identified some bizarre bugs in the code, such as in the TArray.InternalSearch() method, see below:

 

class function TArray.InternalSearch<T>(Values: Pointer; Index, Count: Integer; const Item: T;
  out FoundIndex: Integer; Comparer: Pointer): Boolean;
var
  I: Integer;
  Helper: TSearchHelper;
begin
  if (Count <= 0) then
  begin
    if (Count = 0) then
    begin
      FoundIndex := Index;
      Result := True;      <---------- The result cannot be True when Count = 0
      Exit;
    end else
    begin
      raise EArgumentOutOfRangeException.CreateRes(Pointer(@SArgumentOutOfRange));
    end;
  end;

System.Generics.Collections has a similar code and the result is obviously false:

 

class function TArray.DoBinarySearch<T>(const Values: array of T; const Item: T;
  out FoundIndex: NativeInt; const Comparer: IComparer<T>; Index, Count: NativeInt): Boolean;
var
  L, H, mid: NativeInt;
  cmp: NativeInt;
begin
  if Count = 0 then
  begin
    FoundIndex := Index;
    Exit(False);
  end;


I wouldn't expect to find this in a library of this level, unless it has never actually been tested/used.

 

The lack of unit tests is also concerning....

Edited by Alex7691

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×