Natools

Diff
Login

Differences From Artifact [3c3e05eba8]:

To Artifact [ac8c1a7478]:


595
596
597
598
599
600
601

602
603
604
605
606
607
608
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609







+







         Original : constant Dictionary := Dict.Element;
         Worst_Index : constant Dictionary_Entry
           := Worst_Element
              (Original, Counts, Method, First, Last_Code (Original));
         Worst_Value : constant String
           := Dict_Entry (Original, Worst_Index);
         Worst_Count : constant String_Count := Counts (Worst_Index);
         Worst_Removed : Boolean := False;
         Base : constant Dictionary
           := Remove_Element (Original, Worst_Index);
         Old_Score : constant Ada.Streams.Stream_Element_Count := Score;
      begin
         Updated := False;

         for Position in Pending_Words.Iterate loop
616
617
618
619
620
621
622

623
624
625
626
627
628
629
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631







+







                 (Job_Count, New_Dict, Input_Texts, New_Score, New_Counts);

               if New_Score < Score then
                  Dict := Holders.To_Holder (New_Dict);
                  Score := New_Score;
                  Counts := New_Counts;
                  No_Longer_Pending := Position;
                  Worst_Removed := True;
                  Updated := True;
                  Log_Message := Ada.Strings.Unbounded.To_Unbounded_String
                    ("Removing"
                     & Worst_Count'Img & "x "
                     & Natools.String_Escapes.C_Escape_Hex (Worst_Value, True)
                     & ", adding"
                     & Counts (Last_Code (New_Dict))'Img & "x "
647
648
649
650
651
652
653

654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673

674


675
676
677
678
679
680
681
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677

678
679
680
681
682
683
684
685
686







+




















+
-
+
+







                 (Job_Count, Base, Input_Texts, New_Score, New_Counts);

               if New_Score <= Score then
                  Dict := Holders.To_Holder (Base);
                  Score := New_Score;
                  Counts := New_Counts;
                  No_Longer_Pending := String_Lists.No_Element;
                  Worst_Removed := True;
                  Updated := True;
                  Log_Message := Ada.Strings.Unbounded.To_Unbounded_String
                    ("Removing"
                     & Worst_Count'Img & "x "
                     & Natools.String_Escapes.C_Escape_Hex (Worst_Value, True)
                     & ", size"
                     & Score'Img
                     & " ("
                     & Ada.Streams.Stream_Element_Offset'Image
                        (Score - Old_Score)
                     & ')');
               end if;
            end;
         end if;

         if Updated then
            if String_Lists.Has_Element (No_Longer_Pending) then
               Pending_Words.Delete (No_Longer_Pending);
            end if;

            if Worst_Removed then
            Pending_Words.Append (Worst_Value);
               Pending_Words.Append (Worst_Value);
            end if;

            Ada.Text_IO.Put_Line
              (Ada.Text_IO.Current_Error,
               Ada.Strings.Unbounded.To_String (Log_Message));
         end if;
      end Optimization_Round;