[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indent-region for long Java strings very slow
From: |
Chris McMahan |
Subject: |
Re: indent-region for long Java strings very slow |
Date: |
Thu, 26 Oct 2006 13:43:16 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt) |
I think the issue is not the running time of the program, but the time
it takes emacs to parse the string sequence when indenting the java
source code. In that case, it is an emacs issue.
I would agree, however, with David's assessment that it's extremely
inefficient to build a string with the series of concatenated strings,
as Java does construct a separate string object for each
concatenation. StringBuffer, as suggested, would be the way to go
here.
- Chris
David Hansen <david.hansen@gmx.net> writes:
> On 26 Oct 2006 07:15:17 -0700 "giethomas@gmail.com" <giethomas@gmail.com>
> wrote:
>
>> When I build a very long Java String with lots of components (... + ...
>> + ... +), spread out over many lines (each terminated by a newline),
>> indent-region gets very, very slow.
>
> Not emacs related: AFAIK javac creates a new StringBuffer
> object for *each* `+'. So if you don't want your program to
> be unnecessarily slow do something like
>
> String foo = (new StringBuffer ()).append (...)
> .append (...)
> .append (...)
> // ...
> .toString ();
>
> David
>
>
>
--
(. .)
=ooO=(_)=Ooo=====================================
Chris McMahan | first_initiallastname@one.dot.net
=================================================