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: ...@@ -68,8 +68,6 @@ public:
uint8_t readByte() { uint8_t readByte() {
ensure(1); ensure(1);
RELEASE_ASSERT(end > start, "premature eof"); RELEASE_ASSERT(end > start, "premature eof");
if (VERBOSITY("parsing") >= 2)
printf("readByte, now %d %d\n", start + 1, end);
return buf[start++]; return buf[start++];
} }
uint16_t readShort() { return (readByte() << 8) | (readByte()); } uint16_t readShort() { return (readByte() << 8) | (readByte()); }
...@@ -101,16 +99,20 @@ AST_stmt* readASTStmt(BufferedReader* reader); ...@@ -101,16 +99,20 @@ AST_stmt* readASTStmt(BufferedReader* reader);
static std::string readString(BufferedReader* reader) { static std::string readString(BufferedReader* reader) {
int strlen = reader->readShort(); int strlen = reader->readShort();
std::vector<char> chars; llvm::SmallString<32> chars;
for (int i = 0; i < strlen; i++) { for (int i = 0; i < strlen; i++) {
chars.push_back(reader->readByte()); chars.push_back(reader->readByte());
} }
return std::string(chars.begin(), chars.end()); return chars.str().str();
} }
InternedString BufferedReader::readAndInternString() { InternedString BufferedReader::readAndInternString() {
std::string str = readString(this); int strlen = readShort();
return intern_pool->get(std::move(str)); 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) { 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