Commit 5616f91a authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[parser] Use memcmp for keyword checks

Small readability increase for the keyword check magic, using memcmp
instead of a chain of raw comparisons. Could allow better codegen for
memcmp-aware compilers, though in practice seems to have little effect
on generated code.

Change-Id: I91020fe67cebc9270c61c4c678e15217e436afff
Reviewed-on: https://chromium-review.googlesource.com/c/1340291Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57595}
parent ca34f4d0
......@@ -160,16 +160,8 @@ V8_INLINE Token::Value KeywordOrIdentifierToken(const uint8_t* input,
DCHECK_EQ(input[0], keyword[0]); \
DCHECK(token == Token::FUTURE_STRICT_RESERVED_WORD || \
0 == strncmp(keyword, Token::String(token), sizeof(keyword))); \
if (input_length == keyword_length && input[1] == keyword[1] && \
(keyword_length <= 2 || input[2] == keyword[2]) && \
(keyword_length <= 3 || input[3] == keyword[3]) && \
(keyword_length <= 4 || input[4] == keyword[4]) && \
(keyword_length <= 5 || input[5] == keyword[5]) && \
(keyword_length <= 6 || input[6] == keyword[6]) && \
(keyword_length <= 7 || input[7] == keyword[7]) && \
(keyword_length <= 8 || input[8] == keyword[8]) && \
(keyword_length <= 9 || input[9] == keyword[9]) && \
(keyword_length <= 10 || input[10] == keyword[10])) { \
if (input_length == keyword_length && \
memcmp(&input[1], &keyword[1], keyword_length - 1) == 0) { \
return token; \
} \
}
......
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