Natools

Check-in [3a95d52c86]
Login
Overview
Comment:tools/smaz: use the new validation function instead of ad-hoc code
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3a95d52c867f7f19c13715f1567c4ac2f9a4c91a
User & Date: nat on 2016-12-15 20:12:50
Other Links: manifest | tags
Context
2016-12-16
20:55
smaz_generic: optimize compression

For some reason it seems even with -O3, calling Dict_Entry involves a string copy, which makes `memcpy` the larger time consumer of the copmpression algorithm. Inlining it manually improves performance a lot. check-in: 674fadc74b user: nat tags: trunk

2016-12-15
20:12
tools/smaz: use the new validation function instead of ad-hoc code check-in: 3a95d52c86 user: nat tags: trunk
2016-12-14
20:01
smaz_generic: brind the predicate back as a separate function

Since Smaz dictionaries are meant to be global hard-coded constant objects, it makes sense to check the precondition only once, e.g. in a test suite, and not for each and every subprogram call. check-in: ec19d3153c user: nat tags: trunk

Changes

Modified tools/smaz.adb from [7f15ba36a3] to [cd9e4a4669].

1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123

1124
1125
1126
1127
1128
1129
1130
1131
1132
1106
1107
1108
1109
1110
1111
1112











1113


1114
1115
1116
1117
1118
1119
1120







-
-
-
-
-
-
-
-
-
-
-
+
-
-







   is
      Result : Natools.Smaz_256.Dictionary := Dict;
   begin
      Natools.Smaz_Tools.Set_Dictionary_For_Trie_Search
        (Tools_256.To_String_List (Result));
      Result.Hash := Natools.Smaz_Tools.Trie_Search'Access;

      for I in Result.Offsets'Range loop
         if Natools.Smaz_Tools.Trie_Search (Natools.Smaz_256.Dict_Entry
           (Result, I)) /= Natural (I)
         then
            Ada.Text_IO.Put_Line
              (Ada.Text_IO.Current_Error,
               "Fail at" & Ada.Streams.Stream_Element'Image (I)
               & " -> " & Natools.String_Escapes.C_Escape_Hex
                  (Natools.Smaz_256.Dict_Entry (Result, I), True)
               & " ->" & Natural'Image (Natools.Smaz_Tools.Trie_Search
                  (Natools.Smaz_256.Dict_Entry (Result, I))));
      pragma Assert (Natools.Smaz_256.Is_Valid (Result));
         end if;
      end loop;

      return Result;
   end Activate_Dictionary;


   function Activate_Dictionary (Dict : in Natools.Smaz.Dictionary)
     return Natools.Smaz.Dictionary