1
0
Fork 0
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:
Thomas Fletcher 2006-03-23 06:46:43 +00:00
parent d0c9930d89
commit 5085988731

View file

@ -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)
int len = efile.read(tmp);
for(int i = 0; i < len; i++) {
if(tmp[i] == 0) {
len = 0;
break;
str.append((char)tmp);
}
str.append((char)tmp[i]);
}
if(len <= 0) {
break;
}
}
return str.toString();
}