-- Result is an empty string, reuse shared empty string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Left string is empty, return Right string
-- Result is an empty string, reuse shared empty string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Right is an empty string, return Left string
-- Result is an empty string, reuse shared one
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Left is empty string, return Right string
-- Result is an empty string, reuse shared empty string
if Left = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- Result is an empty string, reuse shared empty string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- Result is an empty string, reuse shared empty string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Coefficient is one, just return string itself
-- Empty string requested, return shared empty string
if Max_Length = 0 then
- Reference (Empty_Shared_String'Access);
return Empty_Shared_String'Access;
-- Otherwise, allocate requested space (and probably some more room)
-- Result is an empty string, reuse shared empty string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- Result is empty, reuse shared empty string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- effects if a program references an already-finalized object.
Object.Reference := Null_Unbounded_String.Reference;
- Reference (Object.Reference);
Unreference (SR);
end if;
end Finalize;
-- Result is empty, reuse shared empty string
if Count = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Length of the string is the same as requested, reuse source shared
-- Result is empty, reuse empty shared string
if Count = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- Result is empty, reuse empty shared string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Inserted string is empty, reuse source shared string
-- Result is empty string, reuse empty shared string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- Result is empty string, reuse empty shared string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Result is same as source string, reuse source shared string
-- Result is empty string, reuse empty shared string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
procedure Reference (Item : not null Shared_String_Access) is
begin
+ if Item = Empty_Shared_String'Access then
+ return;
+ end if;
+
System.Atomic_Counters.Increment (Item.Counter);
end Reference;
-- Result is empty string, reuse empty shared string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise allocate new shared string and fill it
-- Result is empty string, reuse empty shared string
if DL = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- In case of empty string, reuse empty shared string
if Source'Length = 0 then
- Reference (Empty_Shared_String'Access);
Target.Reference := Empty_Shared_String'Access;
else
-- For empty result reuse empty shared string
if Count = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Result is whole source string, reuse source shared string
-- Result is empty string, reuse empty shared string
if Count = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
begin
if Source'Length = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
else
begin
if Length = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
else
-- Nothing to translate, reuse empty shared string
if SR.Last = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- Nothing to translate, reuse empty shared string
if SR.Last = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- All blanks, reuse empty shared string
if Low = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
else
-- All blanks, reuse empty shared string
if Low = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- string.
if Low = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
else
-- is empty, reuse empty shared string.
if High = 0 or else DL = 0 then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- string.
if Low = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- is empty, reuse empty shared string.
if High = 0 or else DL = 0 then
- Reference (Empty_Shared_String'Access);
Source.Reference := Empty_Shared_String'Access;
Unreference (SR);
-- Result is empty slice, reuse empty shared string
elsif Low > High then
- Reference (Empty_Shared_String'Access);
DR := Empty_Shared_String'Access;
-- Otherwise, allocate new shared string and fill it
-- Result is empty slice, reuse empty shared string
elsif Low > High then
- Reference (Empty_Shared_String'Access);
Target.Reference := Empty_Shared_String'Access;
Unreference (TR);
Aux : Shared_String_Access := Item;
begin
- if System.Atomic_Counters.Decrement (Aux.Counter) then
-
- -- Reference counter of Empty_Shared_String should never reach
- -- zero. We check here in case it wraps around.
+ if Aux = Empty_Shared_String'Access then
+ return;
+ end if;
- if Aux /= Empty_Shared_String'Access then
- Free (Aux);
- end if;
+ if System.Atomic_Counters.Decrement (Aux.Counter) then
+ Free (Aux);
end if;
end Unreference;