mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
PDOM db: Improves reading char[] from chunks.
This commit is contained in:
parent
b348ab9f8d
commit
a83a57c3ba
2 changed files with 6 additions and 5 deletions
|
@ -90,6 +90,11 @@ public class Chunk {
|
||||||
public char getChar(int offset) {
|
public char getChar(int offset) {
|
||||||
return buffer.getChar(offset % Database.CHUNK_SIZE);
|
return buffer.getChar(offset % Database.CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getCharArray(int offset, char[] result) {
|
||||||
|
buffer.position(offset % Database.CHUNK_SIZE);
|
||||||
|
buffer.asCharBuffer().get(result);
|
||||||
|
}
|
||||||
|
|
||||||
void clear(int offset, int length) {
|
void clear(int offset, int length) {
|
||||||
buffer.position(offset % Database.CHUNK_SIZE);
|
buffer.position(offset % Database.CHUNK_SIZE);
|
||||||
|
|
|
@ -74,11 +74,7 @@ public class ShortString implements IString {
|
||||||
Chunk chunk = db.getChunk(record);
|
Chunk chunk = db.getChunk(record);
|
||||||
int length = chunk.getInt(record + LENGTH);
|
int length = chunk.getInt(record + LENGTH);
|
||||||
char[] chars = new char[length];
|
char[] chars = new char[length];
|
||||||
int p = record + CHARS;
|
chunk.getCharArray(record+CHARS, chars);
|
||||||
for (int i = 0; i < length; ++i) {
|
|
||||||
chars[i] = chunk.getChar(p);
|
|
||||||
p += 2;
|
|
||||||
}
|
|
||||||
return chars;
|
return chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue