Menu

#11 Small Bug Fixes/Performance Enhancements

closed-fixed
nobody
None
5
2006-11-20
2006-11-19
No

When looking through jMemorize's code I noticed the following bugs/issues. These should improve some performance features of the program.

PROBLEM: In PreferencesTool.java's putIntArray function strings are concatenated using '+' inside of a loop. This is inefficient because it results in a StringBuilder being constructed at every iteration. Also, at the end of the function the substring method is used to remove the last comma, but it would be better to avoid having to call substring.
SOLUTION: I replaced the code in the loop to use a StringBuffer and append the data to the the buffer. I designed to loop to stop before adding all elements, so that when it enters the last it does not append a ','. Then the method returns the toString of the StringBuffer

PROBLEM: In CategoryTree.java's getTreeCellRendererComponent function there was an if statement that had no commands inside of it. It has comments but no exucatable commands.
SOLUTION: I commented out the if statement.

PROBLEM: In Localization.java's getAvailableLocales an input stream is opend but it is never closed.
SOLUTION: I added a finally block that closed the stream.

PROBLEM: The Dialog.show method is used in line 87 of AbstractImportAction.java, line 52 of AboutDialog.java, and lines 454 and 474 in MainFrame.java. This function has been deprecated.
SOLUTION: I replaced all instances of show () with setVisible (true);

PROBLEM: The Window.show method is used in lines 53 and 68 in NewCardFramesManager.java. This function has been deprecated.
SOLUTION: I replaced all instances of show () with setVisible (true);

Discussion

  • Sandeep Gill

    Sandeep Gill - 2006-11-19

    Eclipse Patch

     
  • Riad Djemili

    Riad Djemili - 2006-11-20

    Logged In: YES
    user_id=853759
    Originator: NO

    Thanks a lot, I've applied your patch to the development version. It can be found in the current SVN version. There was a small bug: When building the integer array in PreferencesTool, you forgot to add the separator. Other than that the patch was great. Thanks again for your contribution!

    -Riad

     
  • Riad Djemili

    Riad Djemili - 2006-11-20
    • status: open --> closed-fixed
     

Log in to post a comment.