From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "giethomas@gmail.com" Newsgroups: gmane.emacs.help Subject: Re: indent-region for long Java strings very slow Date: 26 Oct 2006 23:56:01 -0700 Organization: http://groups.google.com Message-ID: <1161932161.564077.116050@m73g2000cwd.googlegroups.com> References: <1161872117.135227.178220@i42g2000cwa.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1161934867 1903 80.91.229.2 (27 Oct 2006 07:41:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 27 Oct 2006 07:41:07 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 27 09:41:06 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GdMKP-0001jB-RK for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Oct 2006 09:40:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GdMKP-0007I1-7x for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Oct 2006 03:40:33 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!m73g2000cwd.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 46 Original-NNTP-Posting-Host: 213.132.146.76 Original-X-Trace: posting.google.com 1161932208 29766 127.0.0.1 (27 Oct 2006 06:56:48 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 27 Oct 2006 06:56:48 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20060629 Firefox/1.0.4 (Debian package 1.0.4-2sarge9),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000cwd.googlegroups.com; posting-host=213.132.146.76; posting-account=V663_g0AAAAt4SsP5bgxCO9lR7sUM0Ws Original-Xref: shelby.stanford.edu gnu.emacs.help:142697 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:38317 Archived-At: I agree about the inefficiency of building a string with a series of concatenated strings. but this leaves the emacs issue of parsing the string sequence when indenting the java source code. The problem gets worse and worse with longer source files, even though I only run indent-region. On Oct 26, 7:43 pm, Chris McMahan wrote: > 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 thejava > 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 concatenatedstrings, > asJavadoes construct a separate string object for each > concatenation. StringBuffer, as suggested, would be the way to go > here. > > - Chris > > > > David Hansen writes: > > On 26 Oct 2006 07:15:17 -0700 "gietho...@gmail.com" wrote: > > >> When I build averylongJavaString with lots of components (... + ... > >> + ... +), spread out over many lines (each terminated by a newline), > >>indent-regiongetsvery,veryslow. > > > Not emacs related: AFAIK javac creates a new StringBuffer > > object for *each* `+'. So if you don't want your program to > > be unnecessarilyslowdo something like > > > String foo = (new StringBuffer ()).append (...) > > .append (...) > > .append (...) > > // ... > > .toString (); > > > David-- > (. .) > =ooO=(_)=Ooo===================================== > Chris McMahan | first_initiallastn...@one.dot.net > =================================================