Natools

Check-in [23214105c3]
Login
Overview
Comment:smaz: further reduce the encoder output to fit within the worst case
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 23214105c331ac0b4b09b28639253e762886d95a
User & Date: nat on 2016-09-21 21:14:44
Other Links: manifest | tags
Context
2016-09-22
21:26
smaz-tools: add a function for Hash in dynamically created dictionaries check-in: 418b41afc4 user: nat tags: trunk
2016-09-21
21:14
smaz: further reduce the encoder output to fit within the worst case check-in: 23214105c3 user: nat tags: trunk
2016-09-20
18:17
smaz-tests: add a test case showing bug in compressed size estimation check-in: c65c5954e9 user: nat tags: trunk
Changes

Modified src/natools-smaz.adb from [17ad5eb887] to [e6c590a339].

211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
               Find_Entry;
            end loop Verbatim_Scan;

            Verbatim_Length := Input_Index - Beginning;

            if Previous_Verbatim_Beginning > 0
              and then Output_Last + Verbatim_Size (Dict, Verbatim_Length)
                 > Previous_Verbatim_Last + Verbatim_Size
                    (Dict, Input_Index - Previous_Verbatim_Beginning)
            then
               Beginning := Previous_Verbatim_Beginning;
               Output_Last := Previous_Verbatim_Last;
               Verbatim_Length := Input_Index - Beginning;
            else
               Previous_Verbatim_Beginning := Beginning;







|







211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
               Find_Entry;
            end loop Verbatim_Scan;

            Verbatim_Length := Input_Index - Beginning;

            if Previous_Verbatim_Beginning > 0
              and then Output_Last + Verbatim_Size (Dict, Verbatim_Length)
                 >= Previous_Verbatim_Last + Verbatim_Size
                    (Dict, Input_Index - Previous_Verbatim_Beginning)
            then
               Beginning := Previous_Verbatim_Beginning;
               Output_Last := Previous_Verbatim_Last;
               Verbatim_Length := Input_Index - Beginning;
            else
               Previous_Verbatim_Beginning := Beginning;
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
   end Compress;


   function Compress (Dict : in Dictionary; Input : in String)
     return Ada.Streams.Stream_Element_Array
   is
      Result : Ada.Streams.Stream_Element_Array
        (1 .. Compressed_Upper_Bound (Dict, Input) + 1);
      Last : Ada.Streams.Stream_Element_Offset;
   begin
      Compress (Dict, Input, Result, Last);
      return Result (Result'First .. Last);
   end Compress;









|







263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
   end Compress;


   function Compress (Dict : in Dictionary; Input : in String)
     return Ada.Streams.Stream_Element_Array
   is
      Result : Ada.Streams.Stream_Element_Array
        (1 .. Compressed_Upper_Bound (Dict, Input));
      Last : Ada.Streams.Stream_Element_Offset;
   begin
      Compress (Dict, Input, Result, Last);
      return Result (Result'First .. Last);
   end Compress;