mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Read in more than a single byte at a time to improve performance.
This commit is contained in:
parent
d0c9930d89
commit
5085988731
1 changed files with 17 additions and 6 deletions
|
@ -358,18 +358,29 @@ public class Elf {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String string_from_elf_section(Elf.Section section, int index) throws IOException {
|
protected String string_from_elf_section(Elf.Section section, int index) throws IOException {
|
||||||
StringBuffer str = new StringBuffer();
|
|
||||||
byte tmp;
|
|
||||||
if (index > section.sh_size) {
|
if (index > section.sh_size) {
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringBuffer str = new StringBuffer();
|
||||||
|
//Most string symbols will be less than 50 bytes in size
|
||||||
|
byte [] tmp = new byte[50];
|
||||||
|
|
||||||
efile.seek(section.sh_offset + index);
|
efile.seek(section.sh_offset + index);
|
||||||
while (true) {
|
while(true) {
|
||||||
tmp = efile.readByte();
|
int len = efile.read(tmp);
|
||||||
if (tmp == 0)
|
for(int i = 0; i < len; i++) {
|
||||||
|
if(tmp[i] == 0) {
|
||||||
|
len = 0;
|
||||||
break;
|
break;
|
||||||
str.append((char)tmp);
|
|
||||||
}
|
}
|
||||||
|
str.append((char)tmp[i]);
|
||||||
|
}
|
||||||
|
if(len <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue