Skip to main content
Code Review

Return to Revisions

2 of 2
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/

Currently the it's O(n) where n is the length of the text inside the JTextPane. You could reduce it if you process only the modified regions of the document in the event listener. I think DocumentEvent's getLength() and getOffset() method could help here.

Another notes:

  1. int index = 0, carriage = 0;
    

I'd put the variable declarations to separate lines. From Code Complete, 2nd Edition, p759:

With statements on their own lines, the code reads from top to bottom, instead of top to bottom and left to right. When you’re looking for a specific line of code, your eye should be able to follow the left margin of the code. It shouldn’t have to dip into each and every line just because a single line might contain two statements.

  1. Be aware of static helper classes, like Keywords. You might find my former answer about it useful.
palacsint
  • 30.4k
  • 9
  • 82
  • 157
default

AltStyle によって変換されたページ (->オリジナル) /