Natools

Check-in [0423da4c74]
Login
Overview
Comment:tools/smaz: add support for not removing from pending list in a round
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0423da4c745b97325bb85b573ee715223ef19eb4
User & Date: nat on 2017-05-21 20:44:28
Other Links: manifest | tags
Context
2017-05-22
19:45
tools/smaz: add a dictionary Length accessor check-in: 46f6fa15e8 user: nat tags: trunk
2017-05-21
20:44
tools/smaz: add support for not removing from pending list in a round check-in: 0423da4c74 user: nat tags: trunk
2017-05-20
19:25
tools/smaz: move log-message construction of Optimization_Round check-in: 032d847343 user: nat tags: trunk
Changes

Modified tools/smaz.adb from [9d953a6894] to [5cedb9b4e3].

575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
         Max_Dict_Size : in Positive;
         Updated : out Boolean)
      is
         pragma Unreferenced (Min_Dict_Size);
         pragma Unreferenced (Max_Dict_Size);
         use type Ada.Streams.Stream_Element_Offset;

         New_Position : String_Lists.Cursor;
         Log_Message : Ada.Strings.Unbounded.Unbounded_String;
         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);







|







575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
         Max_Dict_Size : in Positive;
         Updated : out Boolean)
      is
         pragma Unreferenced (Min_Dict_Size);
         pragma Unreferenced (Max_Dict_Size);
         use type Ada.Streams.Stream_Element_Offset;

         No_Longer_Pending : String_Lists.Cursor;
         Log_Message : Ada.Strings.Unbounded.Unbounded_String;
         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);
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630

631


632
633
634
635
636
637
638
               Evaluate_Dictionary
                 (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;
                  New_Position := Position;
                  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 "
                     & Natools.String_Escapes.C_Escape_Hex (Word, True)
                     & ", size"
                     & Score'Img
                     & " ("
                     & Ada.Streams.Stream_Element_Offset'Image
                        (Score - Old_Score)
                     & ')');
               end if;
            end;
         end loop;

         if Updated then

            Pending_Words.Delete (New_Position);


            Pending_Words.Append (Worst_Value);

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







|



















>
|
>
>







604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
               Evaluate_Dictionary
                 (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;
                  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 "
                     & Natools.String_Escapes.C_Escape_Hex (Word, True)
                     & ", size"
                     & Score'Img
                     & " ("
                     & Ada.Streams.Stream_Element_Offset'Image
                        (Score - Old_Score)
                     & ')');
               end if;
            end;
         end loop;

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

            Pending_Words.Append (Worst_Value);

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