Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ansistring

Status
Not open for further replies.

stackdump

Technical User
Sep 21, 2004
278
GB

Hi all,

I have been handed a legacy application to imrpove. This does a huge amount of text and string manipulation and it uses the STRING type throughout. It uses very large arrays of strings and the maximum capacity of the program is limited by available memory.

My first thought is to switch all strings to ansistrings. As I understand it, an ARRAY [1..100] OF STRING will immediately consume 25,600 bytes (?), but an ARRAY [1..100] OF ANSISTRING will consume nothing until a value is assigned to one of the array indices. Also, it will only consume what it requires (i.e. governed by the string length) rather than assuming the full 256 bytes.

Is that a correct interpretation? Is this a reasonable thing to do to quickly lower the memory usage? or am I deluding myself here?


 

I did a quick experiment on this and I can define a much bigger maximum index to an array of string if I define the string as ansistring.

It turns out that FPC has a compile option "-Sh" which causes all strings (even if declared as string) to be interpreted as ansi. So it looks like the task my boss has assigned me for the next two weeks can actually be done in five minutes with a simple recompile!

Guess I'd better do a lot of testing though...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top