mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 11:59:00 +00:00
remove unnecessary use of ReflectApply (#10482)
This commit is contained in:
@@ -145,7 +145,6 @@ export default {
|
||||
ObjectPrototypeToString: uncurryThis(Object.prototype.toString),
|
||||
ObjectSeal: Object.seal,
|
||||
ObjectSetPrototypeOf: Object.setPrototypeOf,
|
||||
ReflectApply: $getByIdDirect(Reflect, "apply"),
|
||||
ReflectOwnKeys: Reflect.ownKeys,
|
||||
RegExp,
|
||||
RegExpPrototypeExec: uncurryThis(RegExp.prototype.exec),
|
||||
|
||||
@@ -93,7 +93,6 @@ const {
|
||||
ObjectPrototypeToString,
|
||||
ObjectSeal,
|
||||
ObjectSetPrototypeOf,
|
||||
ReflectApply,
|
||||
ReflectOwnKeys,
|
||||
RegExp,
|
||||
RegExpPrototypeExec,
|
||||
@@ -314,7 +313,7 @@ const codes = {}; // exported from errors.js
|
||||
msg.length <= args.length, // Default options do not count.
|
||||
`Code: ${sym}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).`,
|
||||
);
|
||||
const message = ReflectApply(msg, error, args);
|
||||
const message = msg.$apply(error, args);
|
||||
|
||||
ObjectDefineProperty(error, "message", { value: message, enumerable: false, writable: true, configurable: true });
|
||||
ObjectDefineProperty(error, "toString", {
|
||||
@@ -1427,7 +1426,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
|
||||
} else if (keys.length > 1) {
|
||||
const sorted = ArrayPrototypeSort(ArrayPrototypeSlice(output, output.length - keys.length), comparator);
|
||||
ArrayPrototypeUnshift(sorted, output, output.length - keys.length, keys.length);
|
||||
ReflectApply(ArrayPrototypeSplice, null, sorted);
|
||||
ArrayPrototypeSplice.$apply(null, sorted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ const ArrayPrototypeSplice = Array.prototype.splice;
|
||||
const ObjectGetPrototypeOf = Object.getPrototypeOf;
|
||||
const ObjectSetPrototypeOf = Object.setPrototypeOf;
|
||||
const SymbolHasInstance = Symbol.hasInstance;
|
||||
const ReflectApply = $getByIdDirect(Reflect, "apply");
|
||||
const PromiseResolve = Promise.resolve;
|
||||
const PromiseReject = Promise.reject;
|
||||
const PromisePrototypeThen = (promise, onFulfilled, onRejected) => promise.then(onFulfilled, onRejected);
|
||||
@@ -146,7 +145,7 @@ class ActiveChannel {
|
||||
runStores(data, fn, thisArg, ...args) {
|
||||
let run = () => {
|
||||
this.publish(data);
|
||||
return ReflectApply(fn, thisArg, args);
|
||||
return fn.$apply(thisArg, args);
|
||||
};
|
||||
|
||||
for (const entry of this._stores.entries()) {
|
||||
@@ -198,7 +197,7 @@ class Channel {
|
||||
publish() {}
|
||||
|
||||
runStores(data, fn, thisArg, ...args) {
|
||||
return ReflectApply(fn, thisArg, args);
|
||||
return fn.$apply(thisArg, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +291,7 @@ class TracingChannel {
|
||||
|
||||
return start.runStores(context, () => {
|
||||
try {
|
||||
const result = ReflectApply(fn, thisArg, args);
|
||||
const result = fn.$apply(thisArg, args);
|
||||
context.result = result;
|
||||
return result;
|
||||
} catch (err) {
|
||||
@@ -327,7 +326,7 @@ class TracingChannel {
|
||||
|
||||
return start.runStores(context, () => {
|
||||
try {
|
||||
let promise = ReflectApply(fn, thisArg, args);
|
||||
let promise = fn.$apply(thisArg, args);
|
||||
// Convert thenables to native promises
|
||||
if (!(promise instanceof Promise)) {
|
||||
promise = PromiseResolve(promise);
|
||||
@@ -358,7 +357,7 @@ class TracingChannel {
|
||||
asyncStart.runStores(context, () => {
|
||||
try {
|
||||
if (callback) {
|
||||
return ReflectApply(callback, this, arguments);
|
||||
return callback.$apply(this, arguments);
|
||||
}
|
||||
} finally {
|
||||
asyncEnd.publish(context);
|
||||
@@ -374,7 +373,7 @@ class TracingChannel {
|
||||
|
||||
return start.runStores(context, () => {
|
||||
try {
|
||||
return ReflectApply(fn, thisArg, args);
|
||||
return fn.$apply(thisArg, args);
|
||||
} catch (err) {
|
||||
context.error = err;
|
||||
error.publish(context);
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
const EventEmitter = require("node:events");
|
||||
const { StringDecoder } = require("node:string_decoder");
|
||||
const internalGetStringWidth = $newZigFunction("string.zig", "String.jsGetStringWidth", 1);
|
||||
const ReflectApply = Reflect.apply;
|
||||
const ObjectGetPrototypeOf = Object.getPrototypeOf;
|
||||
const ObjectGetOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
|
||||
const ObjectValues = Object.values;
|
||||
@@ -187,7 +186,7 @@ function promisify(original) {
|
||||
resolve(values[0]);
|
||||
}
|
||||
});
|
||||
ReflectApply(original, this, args);
|
||||
original.$apply(this, args);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,6 @@ var require_primordials = __commonJS({
|
||||
PromiseReject(err) {
|
||||
return Promise.reject(err);
|
||||
},
|
||||
ReflectApply: $getByIdDirect(Reflect, "apply"),
|
||||
RegExpPrototypeTest(self, value) {
|
||||
return self.test(value);
|
||||
},
|
||||
@@ -5130,7 +5129,7 @@ var require_promises = __commonJS({
|
||||
var require_stream = __commonJS({
|
||||
"node_modules/readable-stream/lib/stream.js"(exports, module) {
|
||||
"use strict";
|
||||
var { ObjectDefineProperty, ObjectKeys, ReflectApply } = require_primordials();
|
||||
var { ObjectDefineProperty, ObjectKeys } = require_primordials();
|
||||
var {
|
||||
promisify: { custom: customPromisify },
|
||||
} = require_util();
|
||||
@@ -5156,7 +5155,7 @@ var require_stream = __commonJS({
|
||||
if (new.target) {
|
||||
throw ERR_ILLEGAL_CONSTRUCTOR();
|
||||
}
|
||||
return Stream.Readable.from(ReflectApply(op, this, args));
|
||||
return Stream.Readable.from(op.$apply(this, args));
|
||||
};
|
||||
const op = streamReturningOperators[key];
|
||||
ObjectDefineProperty(fn, "name", {
|
||||
@@ -5177,7 +5176,7 @@ var require_stream = __commonJS({
|
||||
if (new.target) {
|
||||
throw ERR_ILLEGAL_CONSTRUCTOR();
|
||||
}
|
||||
return ReflectApply(op, this, args);
|
||||
return op.$apply(this, args);
|
||||
};
|
||||
const op = promiseReturningOperators[key];
|
||||
ObjectDefineProperty(fn, "name", {
|
||||
|
||||
Reference in New Issue
Block a user