mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Improve performance DataCOnversion util method to get ASCII from bytes - using string buffer instead of concatentation improves extraction speed by 2 orders of magnitude on larger files
This commit is contained in:
parent
adb3488852
commit
9b22b67c9f
@ -31,7 +31,7 @@ public class DataConversion {
|
|||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
String base = new String(array);
|
String base = new String(array);
|
||||||
|
|
||||||
StringBuilder buff = new StringBuilder();
|
StringBuilder buff = new StringBuilder();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int extra = base.length() % 16;
|
int extra = base.length() % 16;
|
||||||
@ -133,8 +133,8 @@ public class DataConversion {
|
|||||||
Charset.forName("UTF-8").newEncoder();
|
Charset.forName("UTF-8").newEncoder();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String result = "";
|
StringBuilder result = new StringBuilder();
|
||||||
String temp = "";
|
StringBuilder temp = new StringBuilder();
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
//char[] converted = new java.lang.System.Text.Encoding.ASCII.GetString(args).ToCharArray();
|
//char[] converted = new java.lang.System.Text.Encoding.ASCII.GetString(args).ToCharArray();
|
||||||
|
|
||||||
@ -147,26 +147,26 @@ public class DataConversion {
|
|||||||
// the printable ASCII chars are dec 32-126
|
// the printable ASCII chars are dec 32-126
|
||||||
// and we want to include TAB as well (dec 9)
|
// and we want to include TAB as well (dec 9)
|
||||||
if (!((dec < 32 || dec > 126) && dec != 9)) {
|
if (!((dec < 32 || dec > 126) && dec != 9)) {
|
||||||
temp = temp + Character.toString(tempChar);
|
temp.append(Character.toString(tempChar));
|
||||||
counter = counter + 1;
|
counter = counter + 1;
|
||||||
} else {
|
} else {
|
||||||
if (counter >= parameter) {
|
if (counter >= parameter) {
|
||||||
// add to the result and also add the new line at the end
|
// add to the result and also add the new line at the end
|
||||||
result = result + temp + Character.toString(NL);
|
result.append(temp);
|
||||||
|
result.append(Character.toString(NL));
|
||||||
|
|
||||||
// reset the temp and counter
|
// reset the temp and counter
|
||||||
temp = "";
|
temp = new StringBuilder();
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
// reset the temp and counter
|
// reset the temp and counter
|
||||||
temp = "";
|
temp = new StringBuilder();
|
||||||
counter = 0;
|
counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result + temp;
|
result.append(temp);
|
||||||
|
return result.toString();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user