-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assert: refactor to use more primordials
PR-URL: #36234 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
2c7358e
commit e79bdc3
Showing
1 changed file
with
37 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e79bdc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"primordials" seems like massive overkill. If this code were accessed in a million-iteration loop, I could see bypassing the language's native invocation patterns, but for one or two invocations in a test assertion, it seems like one should just use the language as it was written. If performance here is that critical, why not just inline the raw code itself and avoid the stack altogether?
e79bdc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisMiami It's not about performance. In fact, primordials can sometimes hurt performance. It's about preventing Node.js internal code from being affected by userland monkey-patching of globals. Using primordials throughout Node.js internals is a security precaution.
e79bdc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of restating what I said above, but it's not about bypassing the language's native invocation. It's about ensuring the language's native invocation regardless of whatever tampering some module deep in the dependency tree might be doing.