Skip to content

improve removeDuplicateSlashes #318

Closed

Description

@Uzlopak

If we replace the current implementation of removeDuplicateSlashes with the following:

const RemoveDuplicateSlashesRE = /\/\/+/g
function removeDuplicateSlashes (path) {
  return (path.indexOf('//') === -1 && path) || path.replace(RemoveDuplicateSlashesRE, '/')
}

then the case withoout duplicate slashes gets from about 4,284,328 ops/sec up to 5,419,257 ops/sec. The case that we have some duplicate slashes goes from 2,483,375 ops/sec to 2,292,004 ops/sec.

Activity

  1. ivan-tymoshenko commented on Feb 8, 2023

    @ivan-tymoshenko
    Collaborator

    Looks like it's worth it. Go for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions