Skip to content

Performance of MIMEType #120

Closed
Closed
@Uzlopak

Description

@Uzlopak

I think that MIMEType can be improved significantly.

I created rn a PR regarding lazily parsing the MimeParams.

nodejs/node#49889

Also i could improve toASCIILower with this snippet:

const ASCII_LOOKUP = new Array(127).fill(0).map((v, i) => {
  if (i >= 65 && i <= 90) {
    return StringFromCharCode(i + 32);
  }
  return '';
})

function toASCIILower(str) {
  let result = '';
  for (let i = 0; i < str.length; ++i) {
    const code = StringPrototypeCharCodeAt(str, i);

    if (code > 90 || code < 65) {
      result += str[i];
    } else {
      result += ASCII_LOOKUP[code];
    }
  }
  return result;
}

Also why do we use SafeStringPrototypeSearch in encode? Cant we just use RegexPrototypeExec? Cant we manually inline the encode function into toString?

Is there a faster way to iterate the SafeMap? Why do we use a SafeMap and not a NullObject (because of the generator functions?

Can we avoid the generator fns? Does it make sense to avoid the generator fns?

Can we optimize parseTypeAndSubtype? Maybe also lazily parse the values? We need to throw errors in special cases, but other than that, we just have to store the string.

Why do we call in MIMEType toString FunctionPrototypeCall(MIMEParamsStringify, this.#parameters); and not
this.#parameters.toString()?

Questions over questions...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions