This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] PR ada/13470


Tested on i686-linux. Committed on mainline.

PR ada/13470

When Ada.Strings.Unbounded (and the corresponding wide packages) were
rewritten to improve performance by allowing extra expansion space in
unbounded strings, the routines for direct access to the internal
fields of an unbounded string became at the same time very inefficient
(because extra space was removed even for just a read only reference
and an extra copy done), and also incorrect (since the modified version
of Get_Line modified its parameter which is a read only constant). This
patch changes the interface to Get_String in particular so that it can
now be implemented correctly and efficiently. This change is also the
proper clean fix for PR ada/13470, which was about the compiler doing
an "incorrect" optimization based on the assumption that the constant
in parameter was not modified. It turns out that this optimization
though strictly correct, is a bit unfriendly, and in another patch,
we will make sure that this optimization is suppressed for parameters
whose address is taken, but that's not relevant here any more, since
the new interface is much cleaner and avoids the rather nasty kludge
of modifying an in parameter.

At the same time, the implementation of Set_String has been improved
and stream lined to be more efficient (though there was no functional
problem there).

All references to Get_String have been modified to use the new interface,
and one instance in s-spitbo.adb where the rule about not modifying the
data referenced by the pointer returned by Get_String was violated has
been fixed to avoid violating this rule.

In the Unbounded.Text_IO units, the use of Get_String and Set_String
has simply been eliminated (this usage was gratuitous, because these
units are children of Unbounded and have full access to the internal
representation of Unbounded_String in any case.

2005-03-08  Robert Dewar  <dewar@adacore.com>

	PR ada/13470

	* a-stunau.ads, a-stunau.adb: 
	Change interface to allow efficient (and correct) implementation
	The previous changes to allow extra space in unbounded strings had
	left this interface a bit broken.

	* a-suteio.adb: Avoid unnecessary use of Get/Set_String

	* g-spipat.ads, g-spipat.adb: New interface for Get_String
	Minor reformatting (function specs)

	* g-spitbo.adb: New interface for Get_String

	* g-spitbo.ads: Minor reformatting

	* a-swunau.ads, a-swunau.adb: New interface for Get_Wide_String

	* a-szunau.ads, a-szunau.adb: New interface for Get_Wide_Wide_String

Attachment: difs.9
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]