v8/src/unicode-cache-inl.h
Marja Hölttä 2b6780dc17 [scanner] Don't use UnicodeCache for IsLineTerminator.
For such a simple predicate, calling a(n inline) function that checks against
the values is faster (*) than maintaining the cache.

(*) When scanning a file that contains only comments, we're basically calling
IsLineTerminator in a loop. Parsing such files is now 7-18% faster in local
experiments.

BUG=v8:6092

Change-Id: I6a8f2aba9669a76152292f4e6c7853638d15aae3
Reviewed-on: https://chromium-review.googlesource.com/645633
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47810}
2017-09-05 07:04:06 +00:00

44 lines
1.1 KiB
C++

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_UNICODE_CACHE_INL_H_
#define V8_UNICODE_CACHE_INL_H_
#include "src/unicode-inl.h"
#include "src/unicode-cache.h"
namespace v8 {
namespace internal {
bool UnicodeCache::IsIdentifierStart(unibrow::uchar c) {
return kIsIdentifierStart.get(c);
}
bool UnicodeCache::IsIdentifierPart(unibrow::uchar c) {
return kIsIdentifierPart.get(c);
}
bool UnicodeCache::IsLineTerminatorSequence(unibrow::uchar c,
unibrow::uchar next) {
if (!unibrow::IsLineTerminator(c)) return false;
if (c == 0x000d && next == 0x000a) return false; // CR with following LF.
return true;
}
bool UnicodeCache::IsWhiteSpace(unibrow::uchar c) {
return kIsWhiteSpace.get(c);
}
bool UnicodeCache::IsWhiteSpaceOrLineTerminator(unibrow::uchar c) {
return kIsWhiteSpaceOrLineTerminator.get(c);
}
} // namespace internal
} // namespace v8
#endif // V8_UNICODE_CACHE_INL_H_