From: <kp...@us...> - 2009-10-14 10:31:08
|
Revision: 16344 http://jedit.svn.sourceforge.net/jedit/?rev=16344&view=rev Author: kpouer Date: 2009-10-14 10:31:01 +0000 (Wed, 14 Oct 2009) Log Message: ----------- fixed coding style Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2009-10-14 10:29:47 UTC (rev 16343) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2009-10-14 10:31:01 UTC (rev 16344) @@ -110,7 +110,8 @@ } } - if (ruleset.keywords != null) { + if (ruleset.keywords != null) + { if (keywords == null) keywords = new KeywordMap(ignoreCase); keywords.add(ruleset.keywords); Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2009-10-14 10:29:47 UTC (rev 16343) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2009-10-14 10:31:01 UTC (rev 16344) @@ -776,8 +776,10 @@ } //}}} //{{{ matchToken() method - private byte matchToken(ParserRule rule, ParserRule base, LineContext ctx) { - switch (rule.matchType) { + private byte matchToken(ParserRule rule, ParserRule base, LineContext ctx) + { + switch (rule.matchType) + { case ParserRule.MATCH_TYPE_RULE: return base.token; Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java 2009-10-14 10:29:47 UTC (rev 16343) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java 2009-10-14 10:31:01 UTC (rev 16344) @@ -366,8 +366,8 @@ !tag.tagName.equals("END") && !tag.tagName.equals("BEGIN") && !tag.tagName.equals("KEYWORDS") - && !tag.tagName.equals("MODE") - ) { + && !tag.tagName.equals("MODE")) + { byte token = Token.stringToToken(tag.tagName); if(token != -1) addKeyword(tag.lastKeyword.toString(),token); @@ -593,7 +593,7 @@ lastNoWordBreak = "TRUE".equals(attrs.getValue("NO_WORD_BREAK")); lastIgnoreCase = (attrs.getValue("IGNORE_CASE") == null || "TRUE".equals(attrs.getValue("IGNORE_CASE"))); - lastHighlightDigits = "TRUE".equals(attrs.getValue("HIGHLIGHT_DIGITS"));; + lastHighlightDigits = "TRUE".equals(attrs.getValue("HIGHLIGHT_DIGITS")); lastDigitRE = attrs.getValue("DIGIT_RE"); tmp = attrs.getValue("NO_WORD_SEP"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kp...@us...> - 2011-03-22 11:35:48
|
Revision: 19474 http://jedit.svn.sourceforge.net/jedit/?rev=19474&view=rev Author: kpouer Date: 2011-03-22 11:35:42 +0000 (Tue, 22 Mar 2011) Log Message: ----------- Minor optimization making TokenMarker.checkHashString(ParserRule rule) 6 time faster Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java 2011-03-16 19:02:14 UTC (rev 19473) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java 2011-03-22 11:35:42 UTC (rev 19474) @@ -69,7 +69,11 @@ //}}} //{{{ Instance variables - public final String upHashChar; + /** + * The upHashChar should be a String but it is stored + * in an array making iterations much faster + */ + public final char[] upHashChar; public final char[] upHashChars; public final int startPosMatch; public final char[] start; @@ -305,7 +309,7 @@ result.append(",NO_WORD_BREAK=").append((actionHints & NO_WORD_BREAK) != 0); result.append(",IS_ESCAPE=").append((actionHints & IS_ESCAPE) != 0); result.append(",REGEXP=").append((actionHints & REGEXP) != 0); - result.append("],upHashChar=").append(upHashChar); + result.append("],upHashChar=").append(new String(upHashChar)); result.append(",upHashChars=").append(Arrays.toString(upHashChars)); result.append(",startPosMatch="); result.append("[AT_LINE_START=").append((startPosMatch & AT_LINE_START) != 0); @@ -332,7 +336,7 @@ String escape) { this.action = action; - this.upHashChar = null == hashChar ? null : hashChar.toUpperCase(); + this.upHashChar = null == hashChar ? null : hashChar.toUpperCase().toCharArray(); this.upHashChars = null; this.startPosMatch = startPosMatch; this.start = start; Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2011-03-16 19:02:14 UTC (rev 19473) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2011-03-22 11:35:42 UTC (rev 19474) @@ -139,13 +139,13 @@ if (null == r.upHashChars) { keys = new Character[1]; - if ((null == r.upHashChar) || (0 >= r.upHashChar.length())) + if ((null == r.upHashChar) || (0 >= r.upHashChar.length)) { keys[0] = null; } else { - keys[0] = Character.valueOf(r.upHashChar.charAt(0)); + keys[0] = Character.valueOf(r.upHashChar[0]); } } else Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2011-03-16 19:02:14 UTC (rev 19473) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2011-03-22 11:35:42 UTC (rev 19474) @@ -369,7 +369,7 @@ if (null == checkRule.upHashChars) { if (checkRule.upHashChar != null && - (pos + checkRule.upHashChar.length() < line.array.length) && + (pos + checkRule.upHashChar.length < line.array.length) && !checkHashString(checkRule)) { return false; @@ -613,7 +613,7 @@ pattern.array = checkRule.end; pattern.offset = 0; pattern.count = pattern.array.length; - + if(!SyntaxUtilities.regionMatches(context.rules .getIgnoreCase(),line,pos,pattern.array)) { @@ -884,9 +884,9 @@ //{{{ checkHashString() method private boolean checkHashString(ParserRule rule) { - for (int i = 0; i < rule.upHashChar.length(); i++) + for (int i = 0; i < rule.upHashChar.length; i++) { - if (Character.toUpperCase(line.array[pos+i]) != rule.upHashChar.charAt(i)) + if (Character.toUpperCase(line.array[pos+i]) != rule.upHashChar[i]) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <k_s...@us...> - 2012-02-09 19:35:06
|
Revision: 21105 http://jedit.svn.sourceforge.net/jedit/?rev=21105&view=rev Author: k_satoda Date: 2012-02-09 19:34:59 +0000 (Thu, 09 Feb 2012) Log Message: ----------- Eliminated redundant flag variables. This was from SF.net patch #2483695. Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-09 19:02:57 UTC (rev 21104) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-09 19:34:59 UTC (rev 21105) @@ -75,12 +75,11 @@ chunks.width,10)); } - if(chunks.accessable && chunks.visible) + if(chunks.isAccessible() && chunks.glyphs != null) { gfx.setFont(chunks.style.getFont()); gfx.setColor(chunks.style.getForegroundColor()); - - if (glyphVector && chunks.glyphs != null) + if (glyphVector) chunks.drawGlyphs(gfx, x + _x, y); else if(chunks.str != null) { @@ -125,7 +124,7 @@ if(x + _x + chunks.width > clipRect.x && x + _x < clipRect.x + clipRect.width) { - if(chunks.accessable) + if(chunks.isAccessible()) { //{{{ Paint token background color if necessary Color bgColor = chunks.background; @@ -167,7 +166,7 @@ while(chunks != null) { - if(chunks.accessable && offset < chunks.offset + chunks.length) + if(chunks.isAccessible() && offset < chunks.offset + chunks.length) return x + chunks.offsetToX(offset - chunks.offset); x += chunks.width; @@ -193,7 +192,7 @@ while(chunks != null) { - if(chunks.accessable && x < _x + chunks.width) + if(chunks.isAccessible() && x < _x + chunks.width) return chunks.xToOffset(x - _x,round); _x += chunks.width; @@ -251,7 +250,6 @@ //{{{ Package private members //{{{ Instance variables - boolean accessable; boolean initialized; // set up after init() SyntaxStyle style; @@ -263,6 +261,7 @@ { super(Token.NULL,offset,0,rules); this.width = width; + assert !isAccessible(); } //}}} //{{{ Chunk constructor @@ -270,17 +269,26 @@ SyntaxStyle[] styles, byte defaultID) { super(id,offset,length,rules); - accessable = true; style = styles[id]; background = style.getBackgroundColor(); if(background == null) background = styles[defaultID].getBackgroundColor(); + assert isAccessible(); } //}}} + //{{{ isAccessible() method + /** + * Returns true if this chunk has accesible text. + */ + final boolean isAccessible() + { + return length > 0; + } //}}} + //{{{ offsetToX() method final float offsetToX(int offset) { - if(!visible || glyphs == null) + if(glyphs == null) return 0.0f; float x = 0.0f; @@ -303,7 +311,7 @@ //{{{ xToOffset() method final int xToOffset(float x, boolean round) { - if (!visible || glyphs == null) + if (glyphs == null) { if (round && width - x < x) return offset + length; @@ -349,21 +357,17 @@ FontRenderContext fontRenderContext, int physicalLineOffset) { initialized = true; - - if(!accessable) + if(!isAccessible()) { // do nothing } else if(length == 1 && seg.array[seg.offset + offset] == '\t') { - visible = false; float newX = expander.nextTabStop(x,physicalLineOffset+offset); width = newX - x; } else { - visible = true; - str = new String(seg.array,seg.offset + offset,length); char[] textArray = seg.array; @@ -393,9 +397,7 @@ // styles[defaultID].getBackgroundColor() private Color background; private String str; - //private GlyphVector gv; private List<GlyphVector> glyphs; - private boolean visible; //}}} //{{{ getFonts() method Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2012-02-09 19:02:57 UTC (rev 21104) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2012-02-09 19:34:59 UTC (rev 21105) @@ -235,7 +235,7 @@ //{{{ canMerge() method private static boolean canMerge(Chunk c1, Chunk c2, Segment seg) { - if(!c1.accessable || !c2.accessable) + if(!c1.isAccessible() || !c2.isAccessible()) return false; char ch1 = seg.array[seg.offset + c1.offset]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <k_s...@us...> - 2012-02-09 20:06:43
|
Revision: 21106 http://jedit.svn.sourceforge.net/jedit/?rev=21106&view=rev Author: k_satoda Date: 2012-02-09 20:06:37 +0000 (Thu, 09 Feb 2012) Log Message: ----------- Improved some namings and comments to show what's going on. This was from SF.net patch #2483695. Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-09 19:34:59 UTC (rev 21105) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-09 20:06:37 UTC (rev 21106) @@ -257,6 +257,9 @@ //}}} //{{{ Chunk constructor + /** + * Constructs a virtual indent appears at the beggining of a wrapped line. + */ Chunk(float width, int offset, ParserRuleSet rules) { super(Token.NULL,offset,0,rules); @@ -353,7 +356,7 @@ } //}}} //{{{ init() method - void init(Segment seg, TabExpander expander, float x, + void init(Segment lineText, TabExpander expander, float x, FontRenderContext fontRenderContext, int physicalLineOffset) { initialized = true; @@ -361,17 +364,17 @@ { // do nothing } - else if(length == 1 && seg.array[seg.offset + offset] == '\t') + else if(length == 1 && lineText.array[lineText.offset + offset] == '\t') { float newX = expander.nextTabStop(x,physicalLineOffset+offset); width = newX - x; } else { - str = new String(seg.array,seg.offset + offset,length); + str = new String(lineText.array,lineText.offset + offset,length); - char[] textArray = seg.array; - int textStart = seg.offset + offset; + char[] textArray = lineText.array; + int textStart = lineText.offset + offset; width = layoutGlyphs(fontRenderContext, textArray, textStart, Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2012-02-09 19:34:59 UTC (rev 21105) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2012-02-09 20:06:37 UTC (rev 21106) @@ -78,6 +78,8 @@ //{{{ getChunkList() method /** * Returns the list of chunks. + * Each element is a head of linked chunks and represents a + * screen line. * @since jEdit 4.1pre7 */ public List<Chunk> getChunkList() @@ -100,10 +102,11 @@ public void handleToken(Segment seg, byte id, int offset, int length, TokenMarker.LineContext context) { + final Segment lineText = seg; if(id == Token.END) { if(firstToken != null) - out.add(merge((Chunk)firstToken,seg)); + out.add(mergeAdjucentChunks((Chunk)firstToken,lineText)); return; } @@ -115,11 +118,11 @@ if(wrapMargin != 0.0f) { - initChunk(chunk,seg); + initChunk(chunk,lineText); x += chunk.width; - if(Character.isWhitespace(seg.array[ - seg.offset + chunk.offset])) + if(Character.isWhitespace(lineText.array[ + lineText.offset + chunk.offset])) { if(seenNonWhitespace) { @@ -138,13 +141,13 @@ Chunk nextLine = new Chunk(endOfWhitespace, end.offset + end.length, getParserRuleSet(context)); - initChunk(nextLine,seg); + initChunk(nextLine,lineText); nextLine.next = end.next; end.next = null; if(firstToken != null) - out.add(merge((Chunk)firstToken,seg)); + out.add(mergeAdjucentChunks((Chunk)firstToken,lineText)); firstToken = nextLine; @@ -162,7 +165,8 @@ //{{{ Private members - // don't have chunks longer than 100 characters to avoid slowing things down + // Don't have chunks longer than a limit to avoid slowing things down. + // For example, too long chunks are hardly clipped out at rendering. private static final int MAX_CHUNK_LEN = 100; //{{{ Instance variables @@ -191,13 +195,17 @@ } //}}} //{{{ initChunk() method - private void initChunk(Chunk chunk, Segment seg) + private void initChunk(Chunk chunk, Segment lineText) { - chunk.init(seg,expander,x,fontRenderContext, physicalLineOffset); + chunk.init(lineText,expander,x,fontRenderContext, physicalLineOffset); } //}}} - //{{{ merge() method - private Chunk merge(Chunk first, Segment seg) + //{{{ mergeAdjucentChunks() method + /** + * Merges each adjucent chunks if possible, to reduce the number + * of chunks for rendering performance. + */ + private Chunk mergeAdjucentChunks(Chunk first, Segment lineText) { if(first == null) return null; @@ -206,7 +214,7 @@ while(chunk.next != null) { Chunk next = (Chunk)chunk.next; - if(canMerge(chunk,next,seg)) + if(canMerge(chunk,next,lineText)) { // in case already initialized; un-initialize it chunk.initialized = false; @@ -218,7 +226,7 @@ { if(!chunk.initialized) { - initChunk(chunk,seg); + initChunk(chunk,lineText); if(wrapMargin == 0.0f) x += chunk.width; } @@ -227,19 +235,19 @@ } if(!chunk.initialized) - initChunk(chunk,seg); + initChunk(chunk,lineText); return first; } //}}} //{{{ canMerge() method - private static boolean canMerge(Chunk c1, Chunk c2, Segment seg) + private static boolean canMerge(Chunk c1, Chunk c2, Segment lineText) { if(!c1.isAccessible() || !c2.isAccessible()) return false; - char ch1 = seg.array[seg.offset + c1.offset]; - char ch2 = seg.array[seg.offset + c2.offset]; + char ch1 = lineText.array[lineText.offset + c1.offset]; + char ch2 = lineText.array[lineText.offset + c2.offset]; return ((c1.style == c2.style) && ch1 != '\t' && ch2 != '\t' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <k_s...@us...> - 2012-02-11 08:14:55
|
Revision: 21113 http://jedit.svn.sourceforge.net/jedit/?rev=21113&view=rev Author: k_satoda Date: 2012-02-11 08:14:49 +0000 (Sat, 11 Feb 2012) Log Message: ----------- Made tab recognition of a Chunk more explicit as a method. Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-10 23:27:09 UTC (rev 21112) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-11 08:14:49 UTC (rev 21113) @@ -288,6 +288,16 @@ return length > 0; } //}}} + //{{{ isTab() method + /** + * Returns true if this chunk represents a tab. + */ + final boolean isTab(Segment lineText) + { + return length == 1 + && lineText.array[lineText.offset + offset] == '\t'; + } //}}} + //{{{ offsetToX() method final float offsetToX(int offset) { @@ -364,7 +374,7 @@ { // do nothing } - else if(length == 1 && lineText.array[lineText.offset + offset] == '\t') + else if(isTab(lineText)) { float newX = expander.nextTabStop(x,physicalLineOffset+offset); width = newX - x; Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2012-02-10 23:27:09 UTC (rev 21112) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2012-02-11 08:14:49 UTC (rev 21113) @@ -243,15 +243,10 @@ //{{{ canMerge() method private static boolean canMerge(Chunk c1, Chunk c2, Segment lineText) { - if(!c1.isAccessible() || !c2.isAccessible()) - return false; - - char ch1 = lineText.array[lineText.offset + c1.offset]; - char ch2 = lineText.array[lineText.offset + c2.offset]; - - return ((c1.style == c2.style) - && ch1 != '\t' && ch2 != '\t' - && (c1.length + c2.length <= MAX_CHUNK_LEN)); + return c1.style == c2.style + && c1.isAccessible() && !c1.isTab(lineText) + && c2.isAccessible() && !c2.isTab(lineText) + && (c1.length + c2.length) <= MAX_CHUNK_LEN; } //}}} //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Matthieu C. <cho...@gm...> - 2012-02-11 09:57:00
|
Hi Kazutoshi, you should be careful about that, there are million calls of that code, and the performances are critical. Calling a method is slower than having the code directly inline. The JIT compiler will maybe inline it, but if you introduce too much method calls the performances could be slower. Maybe adding comments would be better 2012/2/11 <k_s...@us...> > Revision: 21113 > http://jedit.svn.sourceforge.net/jedit/?rev=21113&view=rev > Author: k_satoda > Date: 2012-02-11 08:14:49 +0000 (Sat, 11 Feb 2012) > Log Message: > ----------- > Made tab recognition of a Chunk more explicit as a method. > > Modified Paths: > -------------- > jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java > jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java > > Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java > =================================================================== > --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-10 > 23:27:09 UTC (rev 21112) > +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2012-02-11 > 08:14:49 UTC (rev 21113) > @@ -288,6 +288,16 @@ > return length > 0; > } //}}} > > + //{{{ isTab() method > + /** > + * Returns true if this chunk represents a tab. > + */ > + final boolean isTab(Segment lineText) > + { > + return length == 1 > + && lineText.array[lineText.offset + offset] == > '\t'; > + } //}}} > + > //{{{ offsetToX() method > final float offsetToX(int offset) > { > @@ -364,7 +374,7 @@ > { > // do nothing > } > - else if(length == 1 && lineText.array[lineText.offset + > offset] == '\t') > + else if(isTab(lineText)) > { > float newX = > expander.nextTabStop(x,physicalLineOffset+offset); > width = newX - x; > > Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java > =================================================================== > --- jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java > 2012-02-10 23:27:09 UTC (rev 21112) > +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java > 2012-02-11 08:14:49 UTC (rev 21113) > @@ -243,15 +243,10 @@ > //{{{ canMerge() method > private static boolean canMerge(Chunk c1, Chunk c2, Segment > lineText) > { > - if(!c1.isAccessible() || !c2.isAccessible()) > - return false; > - > - char ch1 = lineText.array[lineText.offset + c1.offset]; > - char ch2 = lineText.array[lineText.offset + c2.offset]; > - > - return ((c1.style == c2.style) > - && ch1 != '\t' && ch2 != '\t' > - && (c1.length + c2.length <= MAX_CHUNK_LEN)); > + return c1.style == c2.style > + && c1.isAccessible() && !c1.isTab(lineText) > + && c2.isAccessible() && !c2.isTab(lineText) > + && (c1.length + c2.length) <= MAX_CHUNK_LEN; > } //}}} > > //}}} > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > jEdit-CVS mailing list > jEd...@li... > https://lists.sourceforge.net/lists/listinfo/jedit-cvs > |
From: <kp...@us...> - 2020-04-15 15:14:51
|
Revision: 25244 http://sourceforge.net/p/jedit/svn/25244 Author: kpouer Date: 2020-04-15 15:14:49 +0000 (Wed, 15 Apr 2020) Log Message: ----------- some cleanup Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java jEdit/trunk/org/gjt/sp/jedit/syntax/DefaultTokenHandler.java jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java jEdit/trunk/org/gjt/sp/jedit/syntax/DummyTokenHandler.java jEdit/trunk/org/gjt/sp/jedit/syntax/KeywordMap.java jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java jEdit/trunk/org/gjt/sp/jedit/syntax/Token.java jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -45,6 +45,9 @@ */ public class Chunk extends Token { + public static final Font[] EMPTY_FONT_ARRAY = new Font[0]; + public static final GlyphVector[] EMPTY_GLYPH_VECTOR_ARRAY = new GlyphVector[0]; + //{{{ paintChunkList() method /** * Paints a chunk list. @@ -228,7 +231,7 @@ } - List<Font> userFonts = new ArrayList<Font>(); + List<Font> userFonts = new ArrayList<>(); String family; int i = 0; @@ -242,14 +245,13 @@ * check skips fonts that don't exist. */ Font f = Font.decode(props.getProperty("view.fontSubstList." + i)); - if (f != null && (!"dialog".equalsIgnoreCase(f.getFamily()) || - "dialog".equalsIgnoreCase(family))) + if (!"dialog".equalsIgnoreCase(f.getFamily()) || "dialog".equalsIgnoreCase(family)) userFonts.add(f); i++; } } - preferredFonts = userFonts.toArray(new Font[userFonts.size()]); + preferredFonts = userFonts.toArray(EMPTY_FONT_ARRAY); // Clear cache, not to hold reference to old fonts which // might become unused after properties changed. @@ -746,7 +748,7 @@ // logic find intermediate boundaries. private static class FontSubstitution { - public FontSubstitution(Font mainFont, FontRenderContext frc, + FontSubstitution(Font mainFont, FontRenderContext frc, char[] text, int start) { this.mainFont = mainFont; @@ -793,7 +795,7 @@ public GlyphVector[] getGlyphs() { - return glyphs.toArray(new GlyphVector[glyphs.size()]); + return glyphs.toArray(EMPTY_GLYPH_VECTOR_ARRAY); } private final Font mainFont; @@ -882,7 +884,7 @@ //{{{ class GlyphCache private static class GlyphCache extends LinkedHashMap<GlyphKey, GlyphVector[]> { - public GlyphCache(int capacity) + GlyphCache(int capacity) { // Avoid rehashing with known limit. super(capacity + 1, 1.0f, true/*accessOrder*/); Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DefaultTokenHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/DefaultTokenHandler.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DefaultTokenHandler.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -63,6 +63,7 @@ * @param context The line context * @since jEdit 4.2pre3 */ + @Override public void handleToken(Segment seg, byte id, int offset, int length, TokenMarker.LineContext context) { @@ -92,6 +93,7 @@ * retokenized). * @since jEdit 4.2pre6 */ + @Override public void setLineContext(TokenMarker.LineContext lineContext) { this.lineContext = lineContext; Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DisplayTokenHandler.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -192,7 +192,7 @@ * Merges each adjucent chunks if possible, to reduce the number * of chunks for rendering performance. */ - private void mergeAdjucentChunks(Chunk lineHead, Segment lineText) + private static void mergeAdjucentChunks(Chunk lineHead, Segment lineText) { Chunk chunk = lineHead; while(chunk.next != null) @@ -406,7 +406,7 @@ { public static final int DONE = -1; - public LineBreaker(Segment lineText, int startOffset) + LineBreaker(Segment lineText, int startOffset) { iterator = new LineBreakIterator(); iterator.setText(lineText); @@ -462,7 +462,7 @@ */ private static class LineBreakIterator extends BreakIterator { - public LineBreakIterator() + LineBreakIterator() { base = BreakIterator.getLineInstance(); } Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/DummyTokenHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/DummyTokenHandler.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/DummyTokenHandler.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -51,6 +51,7 @@ * @param context The line context * @since jEdit 4.2pre3 */ + @Override public void handleToken(Segment seg, byte id, int offset, int length, TokenMarker.LineContext context) {} //}}} @@ -62,6 +63,7 @@ * retokenized). * @since jEdit 4.2pre6 */ + @Override public void setLineContext(TokenMarker.LineContext lineContext) { } //}}} Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/KeywordMap.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/KeywordMap.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/KeywordMap.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -149,7 +149,7 @@ */ public String[] getKeywords() { - List<String> vector = new ArrayList<String>(100); + List<String> vector = new ArrayList<>(100); for (Keyword kw : map) { Keyword keyword = kw; @@ -206,8 +206,8 @@ //{{{ Private members //{{{ Instance variables - private int mapLength; - private Keyword[] map; + private final int mapLength; + private final Keyword[] map; private boolean ignoreCase; private StringBuilder noWordSep; //}}} Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRule.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -347,8 +347,7 @@ this.delegate = delegate; this.token = token; this.matchType = matchType; - this.escapeRule = (escape != null && escape.length() > 0) ? - createEscapeRule(escape) : null; + escapeRule = escape != null && !escape.isEmpty() ? createEscapeRule(escape) : null; if(this.delegate == null) { @@ -367,7 +366,7 @@ { this.action = action; this.upHashChar = null; - Set<Character> hashCharsSet = new HashSet<Character>(); + Set<Character> hashCharsSet = new HashSet<>(); for (char c : hashChars) { hashCharsSet.add(Character.toUpperCase(c)); @@ -388,8 +387,7 @@ this.delegate = delegate; this.token = token; this.matchType = matchType; - this.escapeRule = (escape != null && escape.length() > 0) ? - createEscapeRule(escape) : null; + this.escapeRule = escape != null && !escape.isEmpty() ? createEscapeRule(escape) : null; if(this.delegate == null) { Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -192,7 +192,7 @@ else { int size = rulesForNull.size() + rulesForKey.size(); - List<ParserRule> mixed = new ArrayList<ParserRule>(size); + List<ParserRule> mixed = new ArrayList<>(size); mixed.addAll(rulesForKey); mixed.addAll(rulesForNull); return mixed; Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Token.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Token.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Token.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -61,7 +61,7 @@ } //}}} //{{{ Token types - public static final String[] TOKEN_TYPES = new String[] { + public static final String[] TOKEN_TYPES = { "NULL", "COMMENT1", "COMMENT2", Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -46,6 +46,9 @@ */ public class TokenMarker { + + public static final ParserRuleSet[] EMPTY_PARSER_RULE_SETS_ARRAY = new ParserRuleSet[0]; + //{{{ TokenMarker constructor public TokenMarker() {} //}}} @@ -77,7 +80,7 @@ */ public ParserRuleSet[] getRuleSets() { - return ruleSets.values().toArray(new ParserRuleSet[ruleSets.size()]); + return ruleSets.values().toArray(EMPTY_PARSER_RULE_SETS_ARRAY); } //}}} //{{{ markTokens() method @@ -264,7 +267,7 @@ //{{{ Private members //{{{ Instance variables - private final Map<String, ParserRuleSet> ruleSets = new Hashtable<String, ParserRuleSet>(64); + private final Map<String, ParserRuleSet> ruleSets = new Hashtable<>(64); private ParserRuleSet mainRuleSet; // Instead of passing these around to each method, we just store them Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java 2020-04-15 14:51:21 UTC (rev 25243) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/XModeHandler.java 2020-04-15 15:14:49 UTC (rev 25244) @@ -53,6 +53,7 @@ } //}}} //{{{ resolveEntity() method + @Override public InputSource resolveEntity(String publicId, String systemId) { return XMLUtilities.findEntity(systemId, "xmode.dtd", XModeHandler.class); @@ -59,6 +60,7 @@ } //}}} //{{{ characters() method + @Override public void characters(char[] c, int off, int len) { peekElement().setText(c, off, len); @@ -65,6 +67,7 @@ } //}}} //{{{ startElement() method + @Override public void startElement(String uri, String localName, String qName, Attributes attrs) { @@ -113,6 +116,7 @@ } //}}} //{{{ endElement() method + @Override public void endElement(String uri, String localName, String name) { TagDecl tag = popElement(); @@ -393,14 +397,16 @@ } //}}} //{{{ startDocument() method + @Override public void startDocument() { - props = new Hashtable<String, String>(); + props = new Hashtable<>(); pushElement(null, null); - reloadModes = new Vector<Mode>(); + reloadModes = new Vector<>(); } //}}} //{{{ endDocument() method + @Override public void endDocument() { ParserRuleSet[] rulesets = marker.getRuleSets(); @@ -463,12 +469,12 @@ //{{{ Private members //{{{ Instance variables - private String modeName; + private final String modeName; /** The token marker cannot be null. */ private final TokenMarker marker; private KeywordMap keywords; /** this stack can contains null elements. */ - private Stack<TagDecl> stateStack; + private final Stack<TagDecl> stateStack; private String propName; private String propValue; private Hashtable<String, String> props; @@ -541,8 +547,7 @@ */ private class TagDecl { - - public TagDecl(String tagName, Attributes attrs) + TagDecl(String tagName, Attributes attrs) { this.tagName = tagName; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kp...@us...> - 2020-04-24 12:22:20
|
Revision: 25288 http://sourceforge.net/p/jedit/svn/25288 Author: kpouer Date: 2020-04-24 12:22:18 +0000 (Fri, 24 Apr 2020) Log Message: ----------- minor coding style change Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2020-04-24 00:40:38 UTC (rev 25287) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2020-04-24 12:22:18 UTC (rev 25288) @@ -24,6 +24,7 @@ package org.gjt.sp.jedit.syntax; //{{{ Imports +import javax.annotation.Nullable; import javax.swing.text.*; import java.awt.font.*; import java.awt.geom.*; @@ -424,7 +425,7 @@ */ final Chunk snippetBeforeLineOffset(int lineOffset) { - return snippetBefore(lineOffset - this.offset); + return snippetBefore(lineOffset - offset); } //}}} //{{{ offsetToX() method @@ -757,7 +758,7 @@ rangeStart = start; rangeFont = null; rangeLength = 0; - glyphs = new ArrayList<GlyphVector>(); + glyphs = new ArrayList<>(); } public void addNonSubstRange(int length) @@ -802,6 +803,7 @@ private final FontRenderContext frc; private final char[] text; private int rangeStart; + @Nullable private Font rangeFont; private int rangeLength; private final ArrayList<GlyphVector> glyphs; @@ -833,7 +835,7 @@ } } GlyphCache newOne = new GlyphCache(glyphCacheCapacity); - glyphCache = new SoftReference<GlyphCache>(newOne); + glyphCache = new SoftReference<>(newOne); return newOne; } //}}} Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2020-04-24 00:40:38 UTC (rev 25287) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/ParserRuleSet.java 2020-04-24 12:22:18 UTC (rev 25288) @@ -51,8 +51,8 @@ { this.modeName = modeName; this.setName = setName; - ruleMap = new HashMap<Character, List<ParserRule>>(); - imports = new ArrayList<ParserRuleSet>(); + ruleMap = new HashMap<>(); + imports = new ArrayList<>(); } //}}} //{{{ getModeName() method @@ -159,12 +159,7 @@ } for (Character key : keys) { - List<ParserRule> rules = ruleMap.get(key); - if (null == rules) - { - rules = new ArrayList<ParserRule>(); - ruleMap.put(key,rules); - } + List<ParserRule> rules = ruleMap.computeIfAbsent(key, k -> new ArrayList<>()); rules.add(r); } } //}}} Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2020-04-24 00:40:38 UTC (rev 25287) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/TokenMarker.java 2020-04-24 12:22:18 UTC (rev 25288) @@ -904,8 +904,7 @@ */ public static class LineContext { - private static final WeakHashMap<LineContext, WeakReference<LineContext>> intern = - new WeakHashMap<LineContext, WeakReference<LineContext>>(); + private static final WeakHashMap<LineContext, WeakReference<LineContext>> intern = new WeakHashMap<>(); public LineContext parent; public ParserRule inRule; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |