Index: src/natools-s_expressions-generic_caches.ads ================================================================== --- src/natools-s_expressions-generic_caches.ads +++ src/natools-s_expressions-generic_caches.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- 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. -- -- -- @@ -94,10 +94,17 @@ 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