Skip to content

Commit 9c48b9d

Browse files
committed
isKeyword optimization for non-keyword fast path.
- Add non-keyword fast path check if first char is '@'. - Avoids full `switch` for data that can't be a keyword. - Array access will just be undefined for empty string. - Performance change depends on data shape, format, and processing algorithm workload. Some synthetic tests with ~80% non-keywords could see 1-3%+ overall increase.
1 parent 28fe0ff commit 9c48b9d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- JSON literal value handling issues (`null` and `[]`).
66
- Fix resolving context `null` values.
77

8+
### Changed
9+
- `isKeyword()` optimization for non-keyword fast path.
10+
811
## 2.0.1 - 2019-12-10
912

1013
### Fixed

lib/context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ api.processingMode = (activeCtx, version) => {
11561156
* @return true if the value is a keyword, false if not.
11571157
*/
11581158
api.isKeyword = v => {
1159-
if(!_isString(v)) {
1159+
if(!_isString(v) || v[0] !== '@') {
11601160
return false;
11611161
}
11621162
switch(v) {

0 commit comments

Comments
 (0)