This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Which Is Faster: String method or finding tree node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Which Is Faster: String method or finding tree node" Watch "Which Is Faster: String method or finding tree node" New topic
Author

Which Is Faster: String method or finding tree node

Isaac Hewitt
Ranch Hand

Joined: Jul 24, 2006
Posts: 190

Wanting to know which is faster in JTree. The directory in question is second from the root. You would have this Root/A/Synopsis
The path is this: String path = DocumentTree.this.getLastSelectedPathComponent().toString();



or would it be faster to find out which child it is.


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

It's a bit hard to understand what exactly you're asking.

Does your code have a performance problem? If not, then is it really worth it to spend a lot of time on optimizing this?

Note that writing code in the form:

is overly verbose, you could just write:

You could rewrite your method like this:

I would also rename the method to isSynopsisDir instead of just synopsisDir to improve readability.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which Is Faster: String method or finding tree node
 
Similar Threads
How to call a servlet from a html
Cost of a call to instanceof
Creating a file
Listing all directories from a given root in batch file
Having trouble reading a file