-
-
Notifications
You must be signed in to change notification settings - Fork 182
remove hasOwnProperty call #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,6 @@ const domainValueRegExp = | |
| const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/; | ||
|
|
||
| const __toString = Object.prototype.toString; | ||
| const __hasOwnProperty = Object.prototype.hasOwnProperty; | ||
|
|
||
| const NullObject = /* @__PURE__ */ (() => { | ||
| const C = function () {}; | ||
|
|
@@ -82,7 +81,7 @@ export interface ParseOptions { | |
| * | ||
| * @default decodeURIComponent | ||
| */ | ||
| decode?: (str: string) => string | undefined; | ||
| decode?: (str: string) => string; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -121,7 +120,7 @@ export function parse( | |
| const key = str.slice(keyStartIdx, keyEndIdx); | ||
|
|
||
| // only assign once | ||
| if (!__hasOwnProperty.call(obj, key)) { | ||
| if (obj[key] === undefined) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you double check performance? I didn’t change this because my numbers were worse doing the undefined check.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, let me bench it
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bench LGTM, would you be free to rebase on main and remove the |
||
| let valStartIdx = startIndex(str, eqIdx + 1, endIdx); | ||
| let valEndIdx = endIndex(str, endIdx, valStartIdx); | ||
|
|
||
|
|
@@ -134,7 +133,8 @@ export function parse( | |
| } | ||
|
|
||
| const value = dec(str.slice(valStartIdx, valEndIdx)); | ||
| if (value !== undefined) obj[key] = value; | ||
|
|
||
| obj[key] = value; | ||
| } | ||
|
|
||
| index = endIdx + 1; | ||
|
|
@@ -366,7 +366,7 @@ export function serialize( | |
| /** | ||
| * URL-decode string value. Optimized to skip native call when no %. | ||
| */ | ||
| function decode(str: string): string | undefined { | ||
| function decode(str: string): string { | ||
| if (str.indexOf("%") === -1) return str; | ||
|
|
||
| try { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.