Open Bug 1976385 Opened 1 year ago Updated 1 year ago

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

People

(Reporter: mayankleoboy1, Unassigned)

References

(Blocks 1 open bug, )

Details

This looks like Array iteration under the R function:

R=(i,e,t)=>i.reduce((n,r)=>[...n,...r.reduce((a,o,l)=>{const h=_(l/(e+t)),c=l%(e+t);return a[h]||(a[h]=[]),c<=e&&a[h].push(o),a},[])],[])

More readable:

function R(i, e, t) {
  function inner(a, o, l) {
    const h = _(l / (e + t));
    const c = l % (e + t);
    if (!a[h]) {
      a[h] = [];
    }
    if (c <= e) {
      a[h].push(o);
    }
    return a;
  };
  function outer(n, r) {
    return [...n, ...r.reduce(inner, [])];
  }
  return i.reduce(outer, []);
}

Adding a fast-path to avoid iteration for array spread in array initialisation should help when executing [...n, ...r.reduce(inner, [])].

Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.