Skip to content

Commit

Permalink
perf: optimize the performance of hyphenate method. (vuejs#6274)
Browse files Browse the repository at this point in the history
  • Loading branch information
sliwey authored and hefeng committed Jan 25, 2019
1 parent 4c65880 commit 99e15ba
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,9 @@ export const capitalize = cached((str: string): string => {
/**
* Hyphenate a camelCase string.
*/
const hyphenateRE = /([^-])([A-Z])/g
const hyphenateRE = /\B([A-Z])/g
export const hyphenate = cached((str: string): string => {
return str
.replace(hyphenateRE, '$1-$2')
.replace(hyphenateRE, '$1-$2')
.toLowerCase()
return str.replace(hyphenateRE, '-$1').toLowerCase()
})

/**
Expand Down

0 comments on commit 99e15ba

Please sign in to comment.