Natools

Check-in [60c4462e44]
Login
Overview
Comment:s_expressions-generic_caches: add a cheaper-when-possible alternative to Move
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1: 60c4462e442e61a55f126a3879806df04180780d
User & Date: nat on 2019-04-11 17:43:01
Other Links: manifest | tags
Context
2019-04-11
17:43
s_expressions-generic_caches: add a cheaper-when-possible alternative to Move Leaf check-in: 60c4462e44 user: nat tags: trunk
2019-04-10
19:49
s_expressions-enumeration_io-tests: test Value of invalid enum atoms check-in: b63c559d17 user: nat tags: trunk
Changes

Modified src/natools-s_expressions-generic_caches.ads from [00246a7ed7] to [cca6fa2cca].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, Natacha Porté                                   --
-- Copyright (c) 2013-2019, 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         --
92
93
94
95
96
97
98







99
100
101
102
103
104
105
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112







+
+
+
+
+
+
+







      --  Create a new Cursor pointing at the beginning of Cache

   function Move (Source : in out S_Expressions.Descriptor'Class) return Cursor
     is (Move (Source).First);
      --  Return a cursor holding a copy of Original (which is
      --  destructively read)

   function Conditional_Move
     (Source : in out S_Expressions.Descriptor'Class)
     return Cursor
     is (if Source in Cursor then Cursor (Source) else Move (Source).First);
      --  Return a copy of Source, with cheap copy if possible,
      --  otherwise with destructive Move

private

   type Atom_Access is access Atom;
   for Atom_Access'Storage_Pool use Atom_Pool;
   procedure Unchecked_Free is new Ada.Unchecked_Deallocation
     (Atom, Atom_Access);