AD3: A bit faster exporting due turning off Highlighting

This commit is contained in:
Jindra Pet��k
2012-12-20 10:46:17 +01:00
parent 0b81a8686e
commit f6250b92ca
3 changed files with 31 additions and 2 deletions
+5 -1
View File
@@ -589,6 +589,10 @@ public class ABC {
} }
public String classToString(int i, boolean highlight, boolean pcode) { public String classToString(int i, boolean highlight, boolean pcode) {
if(!highlight)
{
Highlighting.doHighlight=false;
}
String ret = ""; String ret = "";
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos); PrintStream out = new PrintStream(baos);
@@ -740,7 +744,7 @@ public class ABC {
out.println(IDENT_STRING + "}");//class out.println(IDENT_STRING + "}");//class
out.println("}");//package out.println("}");//package
out.flush(); out.flush();
Highlighting.doHighlight=true;
return baos.toString(); return baos.toString();
} }
@@ -821,7 +821,7 @@ public class AVM2Code {
} }
return ret; return ret;
} }
public int pos2adr(int pos) { public int pos2adr(int pos) {
if(!cacheActual){ if(!cacheActual){
buildCache(); buildCache();
@@ -40,6 +40,11 @@ public class Highlighting {
*/ */
public long offset; public long offset;
/**
* Turn hignlighting on/off
*/
public static boolean doHighlight=true;
/** /**
* Returns a string representation of the object * Returns a string representation of the object
* *
@@ -49,6 +54,8 @@ public class Highlighting {
public String toString() { public String toString() {
return "" + startPos + "-" + (startPos + len) + " ofs" + offset; return "" + startPos + "-" + (startPos + len) + " ofs" + offset;
} }
/** /**
* Constructor * Constructor
@@ -85,6 +92,9 @@ public class Highlighting {
* @return Highlighted text * @return Highlighted text
*/ */
public static String hilighOffset(String text, long offset) { public static String hilighOffset(String text, long offset) {
if(!doHighlight){
return text;
}
return OFSOPEN + offset + OFSCLOSE + text + OFSEND; return OFSOPEN + offset + OFSCLOSE + text + OFSEND;
} }
@@ -96,6 +106,9 @@ public class Highlighting {
* @return Highlighted text * @return Highlighted text
*/ */
public static String hilighMethod(String text, long index) { public static String hilighMethod(String text, long index) {
if(!doHighlight){
return text;
}
return hilighMethodBegin(index) + text + hilighMethodEnd(); return hilighMethodBegin(index) + text + hilighMethodEnd();
} }
@@ -105,6 +118,9 @@ public class Highlighting {
* @return * @return
*/ */
public static String hilighMethodBegin(long index) { public static String hilighMethodBegin(long index) {
if(!doHighlight){
return "";
}
return METHODOPEN + index + METHODCLOSE; return METHODOPEN + index + METHODCLOSE;
} }
@@ -113,6 +129,9 @@ public class Highlighting {
* @return * @return
*/ */
public static String hilighMethodEnd() { public static String hilighMethodEnd() {
if(!doHighlight){
return "";
}
return METHODEND; return METHODEND;
} }
/** /**
@@ -123,6 +142,9 @@ public class Highlighting {
* @return Highlighted text * @return Highlighted text
*/ */
public static String hilighTrait(String text, long offset) { public static String hilighTrait(String text, long offset) {
if(!doHighlight){
return text;
}
return TRAITOPEN + offset + TRAITCLOSE + text + TRAITEND; return TRAITOPEN + offset + TRAITCLOSE + text + TRAITEND;
} }
@@ -133,6 +155,9 @@ public class Highlighting {
* @return Text with no highlights * @return Text with no highlights
*/ */
public static String stripHilights(String text) { public static String stripHilights(String text) {
if(!doHighlight){
return text;
}
text = stripInstrHilights(text); text = stripInstrHilights(text);
text = stripTraitHilights(text); text = stripTraitHilights(text);
text = stripMethodHilights(text); text = stripMethodHilights(text);