Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: src/snapshot-source-sink.h

Issue 1008923003: Serializer: micro-optimizations for the deserializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add assertion Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.cc ('k') | src/snapshot-source-sink.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot-source-sink.h
diff --git a/src/snapshot-source-sink.h b/src/snapshot-source-sink.h
index 66feaecca4ff5024b63838cf9c040aea3f172591..6612029a9075bbbc40b794050f7cdf8c72152b36 100644
--- a/src/snapshot-source-sink.h
+++ b/src/snapshot-source-sink.h
@@ -36,16 +36,18 @@ class SnapshotByteSource FINAL {
return data_[position_++];
}
- int32_t GetUnalignedInt();
-
void Advance(int by) { position_ += by; }
void CopyRaw(byte* to, int number_of_bytes);
inline int GetInt() {
- // This way of variable-length encoding integers does not suffer from branch
- // mispredictions.
- uint32_t answer = GetUnalignedInt();
+ // This way of decoding variable-length encoded integers does not
+ // suffer from branch mispredictions.
+ DCHECK(position_ + 3 < length_);
+ uint32_t answer = data_[position_];
+ answer |= data_[position_ + 1] << 8;
+ answer |= data_[position_ + 2] << 16;
+ answer |= data_[position_ + 3] << 24;
int bytes = (answer & 3) + 1;
Advance(bytes);
uint32_t mask = 0xffffffffu;
« no previous file with comments | « src/serialize.cc ('k') | src/snapshot-source-sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698