Re: Memory allocation overhead

Lothar Scholz <[email protected]>
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Organization Scriptolutions
Message-ID <[email protected]>
Hello Colin,

Friday, March 28, 2008, 7:50:06 PM, you wrote:

>>>>>> "Eric" == Eric Bezault <[email protected]> writes:

CPA>     Eric> Otherwise I try to be very careful with
CPA>     Eric> strings. String concatenations and substring operations
CPA>     Eric> create a lot of intermediary objects. Be careful as well
CPA>     Eric> when strings get resized (even implicitly by some
CPA>     Eric> operations).

CPA> Is there a more efficient way of doing this sort of thing?

CPA>    a_preceding_path := parent.path
CPA>     if STRING_.same_string (a_preceding_path, "/") then
CPA>         Result := STRING_.concat (a_preceding_path, node_name)
CPA>     else
CPA>         Result := STRING_.concat (a_preceding_path, "/")
CPA>         Result := STRING_.appended_string (Result, node_name)
CPA>         Result := STRING_.appended_string (Result, "[")
CPA>         Result := STRING_.appended_string (Result, simple_number)
CPA>         Result := STRING_.appended_string (Result, "]")
CPA>     end

Exactly for this reason some java compilers have a special optimization
inside the code generator when it detects sequences of strings
concatenations. It's just a to important operation.


-- 
Best regards,
 Lothar                            mailto:[email protected]


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.