Skip to content

Commit aecb675

Browse files
crisbetothePunderWoman
authored andcommitted
fix(core): avoid repeated work when parsing version (#53598)
The `Version` class was splitting the same value 3 times instead of doing it once and reusing the result. PR Close #53598
1 parent dda656e commit aecb675

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/core/src/version.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ export class Version {
1717
public readonly patch: string;
1818

1919
constructor(public full: string) {
20-
this.major = full.split('.')[0];
21-
this.minor = full.split('.')[1];
22-
this.patch = full.split('.').slice(2).join('.');
20+
const parts = full.split('.');
21+
this.major = parts[0];
22+
this.minor = parts[1];
23+
this.patch = parts.slice(2).join('.');
2324
}
2425
}
2526

0 commit comments

Comments
 (0)