Natools

Check-in [7521b2a2e6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:string_slices-slice_sets: drop uneeded mutability of string references
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7521b2a2e6de6d19d30c82c73381f6c58110505c
User & Date: nat 2017-06-13 19:15:59
Context
2017-06-14
20:58
string_slices: new callback-based constructor check-in: cd40fb63c6 user: nat tags: trunk
2017-06-13
19:15
string_slices-slice_sets: drop uneeded mutability of string references check-in: 7521b2a2e6 user: nat tags: trunk
2017-06-12
19:15
string_slices: use an immutable reference to protect from overwriting check-in: 74bf50894a user: nat tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/natools-string_slices-slice_sets.adb.

1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013-2016, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
      end if;

      Set.Bounds.Insert (Bounds);
   end Add_Slice;


   procedure Add_Slice (Set : in out Slice_Set; S : in Slice) is
      use type String_Refs.Reference;
   begin
      if S.Bounds.Length = 0 then
         return;
      end if;

      if Set.Ref.Is_Empty then
         pragma Assert (Set.Bounds.Is_Empty);







|







563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
      end if;

      Set.Bounds.Insert (Bounds);
   end Add_Slice;


   procedure Add_Slice (Set : in out Slice_Set; S : in Slice) is
      use type String_Refs.Immutable_Reference;
   begin
      if S.Bounds.Length = 0 then
         return;
      end if;

      if Set.Ref.Is_Empty then
         pragma Assert (Set.Bounds.Is_Empty);
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
      end if;

      Include_Range (Set.Bounds, Bounds);
   end Include_Slice;


   procedure Include_Slice (Set : in out Slice_Set; S : in Slice) is
      use type String_Refs.Reference;
   begin
      if S.Bounds.Length = 0 then
         return;
      end if;

      if Set.Ref.Is_Empty then
         pragma Assert (Set.Bounds.Is_Empty);







|







619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
      end if;

      Include_Range (Set.Bounds, Bounds);
   end Include_Slice;


   procedure Include_Slice (Set : in out Slice_Set; S : in Slice) is
      use type String_Refs.Immutable_Reference;
   begin
      if S.Bounds.Length = 0 then
         return;
      end if;

      if Set.Ref.Is_Empty then
         pragma Assert (Set.Bounds.Is_Empty);

Changes to src/natools-string_slices-slice_sets.ads.

1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013-2016, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
223
224
225
226
227
228
229
230
231
232
233
   procedure Include_Range (Set : in out Range_Set; Bounds : in String_Range);
   procedure Exclude_Range (Set : in out Range_Set; Bounds : in String_Range);
      --  Perform ensemble union and subtraction of index sets


   type Slice_Set is tagged record
      Bounds : Range_Set;
      Ref : String_Refs.Reference;
   end record;

end Natools.String_Slices.Slice_Sets;







|



223
224
225
226
227
228
229
230
231
232
233
   procedure Include_Range (Set : in out Range_Set; Bounds : in String_Range);
   procedure Exclude_Range (Set : in out Range_Set; Bounds : in String_Range);
      --  Perform ensemble union and subtraction of index sets


   type Slice_Set is tagged record
      Bounds : Range_Set;
      Ref : String_Refs.Immutable_Reference;
   end record;

end Natools.String_Slices.Slice_Sets;