Natools

Check-in [6eaac2a01c]
Login
Overview
Comment:tools/smaz: use the new version of Worst_Index
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6eaac2a01ca5beaf5afde45a9e7aa11c5d404018
User & Date: nat on 2017-05-17 21:44:12
Other Links: manifest | tags
Context
2017-05-18
21:13
tools/smaz: implement forced words for optimized dictionary generation check-in: 014ca1d01b user: nat tags: trunk
2017-05-17
21:44
tools/smaz: use the new version of Worst_Index check-in: 6eaac2a01c user: nat tags: trunk
2017-05-16
21:25
smaz-tools: new version of Worst_Index limited to a range check-in: 5388213f83 user: nat tags: trunk
Changes

Modified tools/smaz.adb from [c932ff0009] to [e22ccc7ac2].

321
322
323
324
325
326
327
328


329
330
331
332
333
334
335
321
322
323
324
325
326
327

328
329
330
331
332
333
334
335
336







-
+
+







        (List : in String_Lists.List;
         Variable_Length_Verbatim : in Boolean)
        return Dictionary;

      with function Worst_Element
        (Dict : in Dictionary;
         Counts : in Dictionary_Counts;
         Method : in Methods)
         Method : in Methods;
         First, Last : in Dictionary_Entry)
        return Dictionary_Entry;

   package Dictionary_Subprograms is

      package Holders is new Ada.Containers.Indefinite_Holders (Dictionary);

      function Adjust_Dictionary
451
452
453
454
455
456
457
458



459
460
461
462
463
464
465
452
453
454
455
456
457
458

459
460
461
462
463
464
465
466
467
468







-
+
+
+







               end if;
            end loop;

            for Word of Handler.Forced_Words loop
               if not Is_In_Dict (Actual_Dict, Word) then
                  declare
                     Worst_Index : constant Dictionary_Entry
                       := Worst_Element (Actual_Dict, Counts, Method);
                       := Worst_Element
                          (Actual_Dict, Counts, Method,
                           Dictionary_Entry'First, Last_Code (Actual_Dict));
                     New_Dict : constant Dictionary
                       := Replace_Element (Current.Element, Worst_Index, Word);
                  begin
                     Ada.Text_IO.Put_Line
                       (Ada.Text_IO.Current_Error,
                        "Removing"
                        & Counts (Worst_Index)'Img & "x "
560
561
562
563
564
565
566
567



568
569
570
571
572
573
574
563
564
565
566
567
568
569

570
571
572
573
574
575
576
577
578
579







-
+
+
+







         Updated : out Boolean)
      is
         use type Ada.Streams.Stream_Element_Offset;

         New_Value : Ada.Strings.Unbounded.Unbounded_String;
         New_Position : String_Lists.Cursor;
         Worst_Index : constant Dictionary_Entry
           := Worst_Element (Dict.Element, Counts, Method);
           := Worst_Element
              (Dict.Element, Counts, Method,
               Dictionary_Entry'First, Last_Code (Dict.Element));
         Worst_Value : constant String
           := Dict_Entry (Dict.Element, Worst_Index);
         Worst_Count : constant String_Count := Counts (Worst_Index);
         Base : constant Dictionary
           := Remove_Element (Dict.Element, Worst_Index);
         Old_Score : constant Ada.Streams.Stream_Element_Count := Score;
      begin