Skip to content

Performance improvement suggestion for mergeConfig function #5606

Closed

Description

@lei-mu

Is your feature request related to a problem? Please describe.

The current implementation of the mergeConfig function in axios does not remove duplicate keys when merging two configuration objects. This can result in unnecessary performance overhead when iterating over duplicated keys.

Describe the solution you'd like

I have submitted a #5605.
To address this issue, I suggest adding a step to remove duplicates from the list of keys before iterating over them. One way to achieve this is by using the uniqueArray helper function provided below:

function uniqueArray(arr) {
  return arr.filter(function(item, index) {
    return arr.indexOf(item) === index;
  });
}

By applying this optimization, we can improve the efficiency of mergeConfig without affecting its functionality or compatibility.
Thank you for considering my suggestion!

Describe alternatives you've considered

No response

Additional context/Screenshots

No response

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