Menu

#81 Improve performace in findMatchingBracket for "no bracket"

closed-accepted
nobody
6
2007-03-13
2007-03-11
No

In org.gjt.sp.jedit.TextUtilities.findMatchingBracket gets a lot of stuff done, even when the current char is no bracket at all.

The patch is quite simple. If "c" is no bracket, return -1 straight away: this way a lot of token handling can get avoided - we would not find a matching bracket anyway.

Index: org/gjt/sp/jedit/TextUtilities.java

--- org/gjt/sp/jedit/TextUtilities.java (Revision 9131)
+++ org/gjt/sp/jedit/TextUtilities.java (Arbeitskopie)
@@ -123,6 +123,11 @@
// corresponding character
char cprime = getComplementaryBracket(c,direction);

+ if( cprime == '\0' )
+ { // c is no bracket
+ return -1;
+ }
+
// 1 because we've already 'seen' the first bracket
int count = 1;

Discussion

  • Marcelo Vanzin

    Marcelo Vanzin - 2007-03-13
    • status: open --> closed-accepted
     
  • Marcelo Vanzin

    Marcelo Vanzin - 2007-03-13

    Logged In: YES
    user_id=75113
    Originator: NO

    Applied, rev #9134.

     

Log in to post a comment.