Commit 5f942f2c authored by Marius Wachtler's avatar Marius Wachtler

Slightly improve the performance of reading in cached parse result

reduces the parse time for 'import pip' from 120ms to 80ms
parent e9fd04b4
......@@ -68,8 +68,6 @@ public:
uint8_t readByte() {
ensure(1);
RELEASE_ASSERT(end > start, "premature eof");
if (VERBOSITY("parsing") >= 2)
printf("readByte, now %d %d\n", start + 1, end);
return buf[start++];
}
uint16_t readShort() { return (readByte() << 8) | (readByte()); }
......@@ -101,16 +99,20 @@ AST_stmt* readASTStmt(BufferedReader* reader);
static std::string readString(BufferedReader* reader) {
int strlen = reader->readShort();
std::vector<char> chars;
llvm::SmallString<32> chars;
for (int i = 0; i < strlen; i++) {
chars.push_back(reader->readByte());
}
return std::string(chars.begin(), chars.end());
return chars.str().str();
}
InternedString BufferedReader::readAndInternString() {
std::string str = readString(this);
return intern_pool->get(std::move(str));
int strlen = readShort();
llvm::SmallString<32> chars;
for (int i = 0; i < strlen; i++) {
chars.push_back(readByte());
}
return intern_pool->get(chars.str());
}
void BufferedReader::readAndInternStringVector(std::vector<InternedString>& v) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment