aspose file tools*
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
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: 14150
    
  18

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