File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which Is Faster: String method or finding tree node

 
Isaac Hewitt
Ranch Hand
Posts: 191
Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic