Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Machine > Re: Optimising ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 801 of 808
Post > Topic >>

Re: Optimising StringBuilder

by "Boudewijn Dijkstra" <usenet@[EMAIL PROTECTED] > Apr 20, 2008 at 01:57 PM

Op Sun, 20 Apr 2008 12:44:22 +0200 schreef Roedy Green  =

<see_website@[EMAIL PROTECTED]
>:
> On Sat, 19 Apr 2008 00:05:37 +0200, "Boudewijn Dijkstra"
> <usenet@[EMAIL PROTECTED]
> wrote, quoted or indirectly quoted
> someone who said :
>
>> Or to do less string manipulation
>
> I can hardly imagine a case where that would be possible, unless you
> mean precomputing hunks of strings or in someway doing the string
> manipulation more efficiently.

Compare
	float f; // distance in parsecs
	System.out.printf("Distance is %3.2f parsecs.\n", f);
versus
	int i; // distance in centiparsecs
	String s =3D String.valueOf(i);
	int dot =3D s.length() - 2;
	System.out.printf("Distance is %s.%s parsecs.\n", s.substring(0, dot), =
 =

s.substring(dot));
..

Compare
	System.out.printf("Distance is %d parsecs.\n", d);
versus
	System.out.print("Distance is ");
	System.out.print(d);
	System.out.println(" parsecs.");
..

Compare
	initialisation:
	 Label myLabel =3D new Label();
	execution:
	 myLabel.setText(String.format("Distance is %d parsecs.", d));
versus
	initialisation:
	 Label myLabel1 =3D new Label("Distance is ");
	 Label myLabel2 =3D new Label();
	 Label myLabel3 =3D new Label(" parsecs.");
	execution:
	 myLabel2.setText(String.valueOf(d));
..




-- =

Gemaakt met Opera's revolutionaire e-mailprogramma:  =

http://www.opera.com/mail/
 




 5 Posts in Topic:
Optimising StringBuilder
Roedy Green <see_websi  2008-04-04 21:19:34 
Re: Optimising StringBuilder
Roedy Green <see_websi  2008-04-04 22:14:42 
Re: Optimising StringBuilder
"Boudewijn Dijkstra&  2008-04-19 00:05:37 
Re: Optimising StringBuilder
Roedy Green <see_websi  2008-04-20 10:44:22 
Re: Optimising StringBuilder
"Boudewijn Dijkstra&  2008-04-20 13:57:38 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 7:21:00 CDT 2008.