AD3: A bit faster exporting due turning off Highlighting

This commit is contained in:
Jindra Petk
2012-12-20 10:46:17 +01:00
parent 0b81a8686e
commit f6250b92ca
3 changed files with 31 additions and 2 deletions

View File

@@ -589,6 +589,10 @@ public class ABC {
}
public String classToString(int i, boolean highlight, boolean pcode) {
if(!highlight)
{
Highlighting.doHighlight=false;
}
String ret = "";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream out = new PrintStream(baos);
@@ -740,7 +744,7 @@ public class ABC {
out.println(IDENT_STRING + "}");//class
out.println("}");//package
out.flush();
Highlighting.doHighlight=true;
return baos.toString();
}

View File

@@ -821,7 +821,7 @@ public class AVM2Code {
}
return ret;
}
public int pos2adr(int pos) {
if(!cacheActual){
buildCache();

View File

@@ -40,6 +40,11 @@ public class Highlighting {
*/
public long offset;
/**
* Turn hignlighting on/off
*/
public static boolean doHighlight=true;
/**
* Returns a string representation of the object
*
@@ -49,6 +54,8 @@ public class Highlighting {
public String toString() {
return "" + startPos + "-" + (startPos + len) + " ofs" + offset;
}
/**
* Constructor
@@ -85,6 +92,9 @@ public class Highlighting {
* @return Highlighted text
*/
public static String hilighOffset(String text, long offset) {
if(!doHighlight){
return text;
}
return OFSOPEN + offset + OFSCLOSE + text + OFSEND;
}
@@ -96,6 +106,9 @@ public class Highlighting {
* @return Highlighted text
*/
public static String hilighMethod(String text, long index) {
if(!doHighlight){
return text;
}
return hilighMethodBegin(index) + text + hilighMethodEnd();
}
@@ -105,6 +118,9 @@ public class Highlighting {
* @return
*/
public static String hilighMethodBegin(long index) {
if(!doHighlight){
return "";
}
return METHODOPEN + index + METHODCLOSE;
}
@@ -113,6 +129,9 @@ public class Highlighting {
* @return
*/
public static String hilighMethodEnd() {
if(!doHighlight){
return "";
}
return METHODEND;
}
/**
@@ -123,6 +142,9 @@ public class Highlighting {
* @return Highlighted text
*/
public static String hilighTrait(String text, long offset) {
if(!doHighlight){
return text;
}
return TRAITOPEN + offset + TRAITCLOSE + text + TRAITEND;
}
@@ -133,6 +155,9 @@ public class Highlighting {
* @return Text with no highlights
*/
public static String stripHilights(String text) {
if(!doHighlight){
return text;
}
text = stripInstrHilights(text);
text = stripTraitHilights(text);
text = stripMethodHilights(text);