Index: src/natools-smaz-tools.adb ================================================================== --- src/natools-smaz-tools.adb +++ src/natools-smaz-tools.adb @@ -803,11 +803,13 @@ procedure Simple_Dictionary_And_Pending (Counter : in Word_Counter; Word_Count : in Natural; Selected : out String_Lists.List; - Pending : out String_Lists.List) + Pending : out String_Lists.List; + Max_Pending_Count : in Ada.Containers.Count_Type + := Ada.Containers.Count_Type'Last) is use type Ada.Containers.Count_Type; Target_Count : constant Ada.Containers.Count_Type := Ada.Containers.Count_Type (Word_Count); Set : Scored_Word_Sets.Set; @@ -822,10 +824,11 @@ for Cursor in Scored_Word_Sets.Iterate (Set) loop if String_Lists.Length (Selected) < Target_Count then Selected.Append (Scored_Word_Sets.Element (Cursor).Word); else Pending.Append (Scored_Word_Sets.Element (Cursor).Word); + exit when String_Lists.Length (Selected) >= Max_Pending_Count; end if; end loop; end Simple_Dictionary_And_Pending; Index: src/natools-smaz-tools.ads ================================================================== --- src/natools-smaz-tools.ads +++ src/natools-smaz-tools.ads @@ -160,11 +160,13 @@ procedure Simple_Dictionary_And_Pending (Counter : in Word_Counter; Word_Count : in Natural; Selected : out String_Lists.List; - Pending : out String_Lists.List); + Pending : out String_Lists.List; + Max_Pending_Count : in Ada.Containers.Count_Type + := Ada.Containers.Count_Type'Last); -- Return in Selected the Word_Count words in Counter that have the -- highest score, and in Pending the remaining words, -- the score being count * length. type Dictionary_Counts is