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 {
|
||||
StringBuffer str = new StringBuffer();
|
||||
byte tmp;
|
||||
if (index > section.sh_size) {
|
||||
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);
|
||||
while (true) {
|
||||
tmp = efile.readByte();
|
||||
if (tmp == 0)
|
||||
while(true) {
|
||||
int len = efile.read(tmp);
|
||||
for(int i = 0; i < len; i++) {
|
||||
if(tmp[i] == 0) {
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
str.append((char)tmp[i]);
|
||||
}
|
||||
if(len <= 0) {
|
||||
break;
|
||||
str.append((char)tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue