Skip to content

[Potential Optimization] Multiple "0 comparisons" with guarenteed positive numbers can be added. #3567

Open
@monoclex

Description

@monoclex

For example, if the compiler knows for a fact that a given set of numbers can only ever be positive or 0, and multiple bounds checks are being performed, the following is possible:

/**
 * @param {Array} a
 * @param {Array} b
 */
function test(a, b) {
	return a.length === 0 && b.length === 0;
}

->

function test(a, b) {
	return a.length + b.length === 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4featFeature Request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions