Skip to content

Commit

Permalink
perf: reuse boolean literal
Browse files Browse the repository at this point in the history
  • Loading branch information
kermanx committed Jan 11, 2025
1 parent b9182c0 commit 8a55cc8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/tree_shaker/src/entity/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,11 @@ impl<'a> EntityFactory<'a> {
}

pub fn boolean(&self, value: bool) -> Entity<'a> {
self.alloc(LiteralEntity::Boolean(value))
if value {
self.r#true
} else {
self.r#false
}
}

pub fn boolean_maybe_unknown(&self, value: Option<bool>) -> Entity<'a> {
Expand Down

1 comment on commit 8a55cc8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test262 Result

  • Failed: 92
  • Total: 43706
  • Passed: 39841
  • Ignored: 1930
  • Treeshaked: 28605, Skipped: 15101
  • Treeshaked sized/Minified size = 86.10%

Failed Tests

language/line-terminators/7.3-15.js: prop.length Expected SameValue(«5», «3») to be true
language/line-terminators/7.3-5.js: { message: 'prop[2] Expected SameValue(«undefined», «\"
language/line-terminators/7.3-6.js: { message: 'prop[2] Expected SameValue(«undefined», «\"
language/source-text/6.1.js: { message: 'A character outside the BMP (Unicode CodePoint > 0xFFFF) should consume two code units' }
language/expressions/async-generator/default-proto.js: { message: 'fn.prototype is undefined Expected SameValue(«[object AsyncGenerator]», «[object AsyncGenerator]») to be true' }
language/expressions/delete/super-property-topropertykey.js: Expected a ReferenceError but got a Test262Error
language/expressions/instanceof/symbol-hasinstance-to-boolean.js: Expected SameValue(«false», «true») to be true
language/expressions/super/prop-expr-getsuperbase-before-topropertykey-putvalue-compound-assign.js: Expected SameValue(«0», «2») to be true
language/expressions/yield/star-iterable.js: Third result 'value' Expected SameValue(«1», «8») to be true
language/statements/class/scope-name-lex-open-heritage.js: inner binding is independent Expected SameValue(«null», «class C extends (probeHeritage=function(){return C},setHeritage=function(){C=null}){method(){return C}}») to be true
language/statements/class/static-init-super-property.js: { message: 'Expected SameValue(«undefined», «\"test262\"») to be true' }
language/statements/class/static-method-gen-non-configurable-err.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/static-method-non-configurable-err.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/for/scope-body-lex-open.js: Expected SameValue(«undefined», «\"outside\"») to be true
language/statements/for/scope-head-lex-close.js: Test timed out
language/statements/for-in/head-const-bound-names-fordecl-tdz.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/for-in/head-let-bound-names-fordecl-tdz.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/for-in/order-simple-object.js: Actual [0, 1, 2, p2, p4] and expected [0, 1, 2, p2, p4, p1] should have the same contents.
language/statements/for-in/scope-head-lex-close.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/for-in/scope-body-lex-open.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/for-in/scope-head-lex-open.js: { message: 'Expected a ReferenceError to be thrown but no exception was thrown at all' }
language/statements/for-of/head-const-bound-names-fordecl-tdz.js: { message: 'Expected a ReferenceError to be thrown but no exception was thrown at all' }
language/statements/for-of/head-expr-obj-iterator-method.js: { message: 'Expected a TypeError to be thrown but no exception was thrown at all' }
language/statements/for-of/head-expr-primitive-iterator-method.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/for-of/head-expr-to-obj.js: { message: 'Expected a TypeError to be thrown but no exception was thrown at all' }
language/statements/for-of/head-let-bound-names-fordecl-tdz.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/function/13.2-2-s.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/function/13.2-4-s.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/let/block-local-closure-set-before-initialization.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/let/function-local-closure-set-before-initialization.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/let/global-closure-set-before-initialization.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/types/number/S8.5_A14_T1.js: #1: 1e+308*2 === Infinity. Actual: Infinity
language/expressions/assignment/dstr/array-elem-put-let.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/expressions/assignment/dstr/array-rest-put-let.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/expressions/assignment/dstr/obj-id-put-let.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/expressions/assignment/dstr/obj-prop-put-let.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/expressions/class/elements/fields-computed-name-static-propname-prototype.js: Expected a TypeError to be thrown but no exception was thrown at all
language/expressions/class/elements/static-private-getter-access-on-inner-arrow-function.js: Accessed static private getter from an object which did not contain it Expected a TypeError to be thrown but no exception was thrown at all
language/expressions/class/elements/static-private-getter-access-on-inner-class.js: { message: 'Accessed static private getter from an object which did not contain it Expected a TypeError to be thrown but no exception was thrown at all' }
language/expressions/class/elements/static-private-getter-access-on-inner-function.js: Accessed static private getter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/expressions/class/elements/static-private-getter.js: Accessed static private getter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/expressions/class/elements/static-private-setter-access-on-inner-arrow-function.js: Accessed static private setter from an object which did not contain it Expected a TypeError to be thrown but no exception was thrown at all
language/expressions/class/elements/static-private-setter-access-on-inner-function.js: Accessed static private setter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/expressions/class/elements/static-private-setter.js: Accessed static private setter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/import/import-defer/deferred-namespace-object/exotic-object-behavior.js: Expected no error, got import: defer*as ns from"./dep_FIXTURE.js";assert.sameValue(typeof ns,"object","Deferred namespaces are objects");assert(!Reflect.isExtensible(ns),"Deferred namespaces are not extensible");assert.sameValue(Reflect.preventExtensions(ns),!0,"Deferred namespaces can made non-extensible");assert.sameValue(Reflect.getPrototypeOf(ns),null,"Deferred namespaces have a null prototype");assert.sameValue(Reflect.setPrototypeOf(ns,{}),!1,"Deferred namespaces' prototype cannot be changed");assert.sameValue(Reflect.setPrototypeOf(ns,null),!0,"Deferred namespaces' prototype can be 'set' to null");assert.throws(TypeError,()=>Reflect.apply(ns,null,[]),"Deferred namespaces are not callable");assert.throws(TypeError,()=>Reflect.construct(ns,[],ns),"Deferred namespaces are not constructable");assert.compareArray(Reflect.ownKeys(ns),["bar","foo",Symbol.toStringTag],"Deferred namespaces' keys are the exports sorted alphabetically, followed by @@toStringTag");verifyProperty(ns,"foo",{value:1,writable:!0,enumerable:!0,configurable:!1});assert.sameValue(Reflect.getOwnPropertyDescriptor(ns,"non-existent"),void 0,"No descriptors for non-exports");
language/import/import-defer/deferred-namespace-object/identity.js: Expected no error, got import: *as nsEager from"./dep_FIXTURE.js";import defer*as nsDeferred1 from"./dep_FIXTURE.js";import defer*as nsDeferred2 from"./dep_FIXTURE.js";import{depDeferredNamespace as nsDeferred3}from"./dep-defer-ns_FIXTURE.js";const nsDeferred4=await importdefer("./dep_FIXTURE.js");assert.sameValue(nsDeferred1,nsDeferred2,"Deferred import of the same module twice gives the same object");assert.sameValue(nsDeferred1,nsDeferred3,"Deferred import of the same module twice from different files gives the same object");assert.sameValue(nsDeferred1,nsDeferred4,"Static and dynamic deferred import of the same module gives the same object");assert.notSameValue(nsDeferred1,nsEager,"Deferred namespaces are distinct from eager namespaces");
language/import/import-defer/deferred-namespace-object/to-string-tag.js: Expected no error, got import: defer*as ns from"./dep_FIXTURE.js";verifyProperty(ns,Symbol.toStringTag,{value:"Deferred Module",writable:!1,enumerable:!1,configurable:!1});
language/import/import-defer/errors/get-self-while-evaluating.js: Expected no error, got import: defer*as self from"./get-self-while-evaluating.js";assert.throws(TypeError,()=>self.foo);
language/import/import-defer/evaluation-sync/evaluation-ignore-get-symbol.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");ns1[Symbol.toStringTag];ns1[Symbol()];assert.sameValue(globalThis.evaluations.length,0,"[[Get]] of a symbol does not trigger evaluation");
language/import/import-defer/evaluation-sync/evaluation-ignore-getPrototypeOf.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");Object.getPrototypeOf(ns1);assert.sameValue(globalThis.evaluations.length,0,"[[GetPrototypeOf]] does not trigger evaluation");
language/import/import-defer/evaluation-sync/evaluation-ignore-isExtensible.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");Object.isExtensible(ns1);assert.sameValue(globalThis.evaluations.length,0,"[[IsExtensible]] does not trigger evaluation");
language/import/import-defer/evaluation-sync/evaluation-ignore-preventExtensions.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");Object.preventExtensions(ns1);assert.sameValue(globalThis.evaluations.length,0,"[[PreventExtensions]] does not trigger evaluation");
language/import/import-defer/evaluation-sync/evaluation-ignore-set.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");try{ns1.foo=2}catch{}try{ns1.ns_1_2=3}catch{}assert.sameValue(globalThis.evaluations.length,0,"[[Set]] of a symbol does not trigger evaluation");
language/import/import-defer/evaluation-sync/evaluation-ignore-setPrototypeOf.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");Reflect.setPrototypeOf(ns1,null);Reflect.setPrototypeOf(ns1,{});assert.sameValue(globalThis.evaluations.length,0,"[[SetPrototypeOf]] does not trigger evaluation");
language/import/import-defer/evaluation-sync/evaluation-trigger-get-string.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");ns1.foo;assert(globalThis.evaluations.length>0,"[[Get]] of a string triggers evaluation");
language/import/import-defer/evaluation-sync/import-defer-does-not-evaluate.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns1 from"./dep-1_FIXTURE.js";assert.sameValue(globalThis.evaluations.length,0,"import defer does not trigger evaluation");const ns_1_2=ns1.ns_1_2;assert.compareArray(globalThis.evaluations,[1.1,1],"when evaluation is triggered, deferred sub-dependencies are not evaluated");ns1.ns_1_2;assert.compareArray(globalThis.evaluations,[1.1,1],"the module is not re-executed");ns_1_2.foo;assert.compareArray(globalThis.evaluations,[1.1,1,1.2]);
language/import/import-defer/evaluation-sync/module-imported-defer-and-eager.js: Expected no error, got import: defer * as ns_1_2 from "./dep-1.2_FIXTURE.js";
language/import/import-defer/syntax/valid-default-binding-named-defer.js: Expected no error, got SyntaxError: Could not resolve import 'default' from /tmp/thmRIGWtSjVKVBuSe8tT/dep_FIXTURE.js
language/statements/class/accessor-name-inst/computed-err-to-prop-key.js: 'get' accessor Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/accessor-name-static/computed-err-to-prop-key.js: 'get' accessor Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/definition/constructable-but-no-prototype.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/definition/getters-non-configurable-err.js: Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/get-access-of-missing-private-static-getter.js: get operation on private accessor without getter should throw TypeError Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/private-accessor-is-visible-in-computed-properties.js: Expected no error, got assert: .throws(TypeError,function(){class __unused_848A{static{this.#f}}},"access to a private acessor from ordinary object");
language/statements/class/elements/private-field-is-visible-in-computed-properties.js: Expected no error, got const: self=this;assert.throws(TypeError,function(){class __unused_848A{static{self.#f}}},"access to a not defined private field in object should throw a TypeError");
language/statements/class/elements/private-field-with-initialized-id-is-visible-in-computed-properties.js: Expected no error, got const: self=this;assert.throws(TypeError,function(){class __unused_848A{static{self.#f}}},"access to a not defined private field in object should throw a TypeError");
language/statements/class/elements/private-method-is-visible-in-computed-properties.js: Expected no error, got assert: .throws(TypeError,function(){class __unused_848A{static{this.#m()}}},"access to a private method from ordinary object");
language/statements/class/elements/static-private-getter-access-on-inner-arrow-function.js: Accessed static private getter from an object which did not contain it Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/static-private-getter-access-on-inner-class.js: Accessed static private getter from an object which did not contain it Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/static-private-getter-access-on-inner-function.js: Accessed static private getter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/static-private-getter.js: Accessed static private getter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/static-private-setter-access-on-inner-arrow-function.js: Accessed static private setter from an object which did not contain it Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/static-private-setter-access-on-inner-function.js: Accessed static private setter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all
language/statements/class/elements/static-private-setter.js: { message: 'Accessed static private setter from an arbitrary object Expected a TypeError to be thrown but no exception was thrown at all' }
language/statements/class/name-binding/in-extends-expression-grouped.js: { message: 'Expected a ReferenceError to be thrown but no exception was thrown at all' }
language/statements/class/name-binding/in-extends-expression-assigned.js: Expected a ReferenceError to be thrown but no exception was thrown at all
language/statements/class/super/in-static-getter.js: The value of 'super.x' is '2' Expected SameValue(«undefined», «2») to be true
language/statements/class/super/in-static-methods.js: The value of 'super.x' is '2' Expected SameValue(«undefined», «2») to be true
language/statements/class/super/in-static-setter.js: The value of 'super.x' is '2' Expected SameValue(«undefined», «2») to be true
language/import/import-defer/errors/get-other-while-dep-evaluating/main.js: Expected no error, got import: defer * as ns_1_2 from "./dep-1.2_FIXTURE.js";
language/import/import-defer/errors/get-other-while-dep-evaluating-async/main.js: Expected no error, got Error: ENOENT: no such file or directory, open '/tmp/mWaGzjV7GMEasSH2tbE1/promises_FIXTURE.js'
language/import/import-defer/errors/get-other-while-evaluating/main.js: Expected no error, got Error: ENOENT: no such file or directory, open '/tmp/EUzU1gK31G85328Giw1u/dep_FIXTURE.js'
language/import/import-defer/errors/get-other-while-evaluating-async/main.js: Expected no error, got Error: ENOENT: no such file or directory, open '/tmp/xHQtXi2x8oAIYLq246t3/promises_FIXTURE.js'
language/import/import-defer/errors/get-self-while-evaluating-async/main.js: Expected no error, got import: defer*as ns from"./dep_FIXTURE.js";assert(globalThis["error on ns.foo"]instanceof TypeError,"ns.foo while evaluating throws a TypeError");ns.foo;$DONE();
language/import/import-defer/errors/get-self-while-defer-evaluating/main.js: Expected no error, got import: defer*as ns from"./dep_FIXTURE.js";assert(globalThis["error on ns.foo"]instanceof TypeError,"ns.foo while evaluating throws a TypeError");ns.foo;
language/import/import-defer/errors/module-throws/third-party-evaluation-after-defer-import.js: Expected no error, got import: defer*as ns from"./throws_FIXTURE.js";asyncTest(async()=>{let err1;await import("./throws_FIXTURE.js").catch(e=>{err1=e});assert.sameValue(err1.someError,"the error from throws_FIXTURE");let err2;try{ns.foo}catch(e){err2=e}assert.sameValue(err1,err2,"Evaluation errors are thrown for modules evaluated after getting the deferred namespace")});
language/import/import-defer/errors/module-throws/defer-import-after-evaluation.js: { message: 'asyncTest called without async flag' }
language/import/import-defer/errors/module-throws/trigger-evaluation.js: Expected no error, got import: defer*as ns from"./throws_FIXTURE.js";let err1,err2;try{ns.foo}catch(e){err1=e}assert.deepEqual(err1,{someError:"the error from throws_FIXTURE"},"Evaluation errors are thrown when evaluating");try{ns.foo}catch(e){err2=e}assert.sameValue(err1,err2,"Evaluation errors are thrown for already evaluated modules");
language/import/import-defer/evaluation-top-level-await/flattening-order/main.js: Expected no error, got import: "./setup_FIXTURE.js";import"./dep-1_FIXTURE.js";import defer*as ns2 from"./dep-2_FIXTURE.js";import"./dep-3_FIXTURE.js";import defer*as ns4 from"./dep-4_FIXTURE.js";import"./dep-5_FIXTURE.js";assert.compareArray(globalThis.evaluations,["1","2.1.1 start","2.2.1","2.2 start","3","5","2.1.1 end","2.2 end","4.1 start","4.1 end","5"]);globalThis.evaluations=[];ns2.x;assert.compareArray(globalThis.evaluations,["2.1","2"]);globalThis.evaluations=[];ns4.x;assert.compareArray(globalThis.evaluations,["4"]);$DONE();
language/import/import-defer/evaluation-top-level-await/import-defer-async-module/main.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns from"./tla_FIXTURE.js";assert.compareArray(globalThis.evaluations,["tla start","tla end"]);ns.x;assert.compareArray(globalThis.evaluations,["tla start","tla end"]);$DONE();
language/import/import-defer/evaluation-top-level-await/import-defer-transitive-async-module/main.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns from"./imports-tla_FIXTURE.js";assert.compareArray(globalThis.evaluations,["tla start","tla end"]);ns.x;assert.compareArray(globalThis.evaluations,["tla start","tla end","imports-tla"]);$DONE();
language/import/import-defer/evaluation-top-level-await/sync-dependency-of-deferred-async-module/main.js: Expected no error, got import: "./setup_FIXTURE.js";import defer*as ns from"./imports-tla-with-dep_FIXTURE.js";assert.compareArray(globalThis.evaluations,["dep","tla-with-dep start","tla-with-dep end"]);ns.x;assert.compareArray(globalThis.evaluations,["dep","tla-with-dep start","tla-with-dep end","imports-tla-with-dep"]);$DONE();

Please sign in to comment.