From a83a57c3baef6baf181762616acc6d63863c0836 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 21 Nov 2006 10:04:03 +0000 Subject: [PATCH] PDOM db: Improves reading char[] from chunks. --- .../parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java | 5 +++++ .../org/eclipse/cdt/internal/core/pdom/db/ShortString.java | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java index 994be08d621..2926e9f27ff 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java @@ -90,6 +90,11 @@ public class Chunk { public char getChar(int offset) { 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) { buffer.position(offset % Database.CHUNK_SIZE); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java index 5db3afcf76d..153eda1ca71 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java @@ -74,11 +74,7 @@ public class ShortString implements IString { Chunk chunk = db.getChunk(record); int length = chunk.getInt(record + LENGTH); char[] chars = new char[length]; - int p = record + CHARS; - for (int i = 0; i < length; ++i) { - chars[i] = chunk.getChar(p); - p += 2; - } + chunk.getCharArray(record+CHARS, chars); return chars; }