refactor(core): optimize calls to `split` and `slice` while computing version parts (#41208)
Reduce the number of calls made to `split` and `slice` while computing version parts by deconstructing the result. PR Close #41208
This commit is contained in:
parent
562a782114
commit
744bd2b64f
|
@ -23,10 +23,10 @@ export class Version {
|
||||||
public readonly patch: string;
|
public readonly patch: string;
|
||||||
|
|
||||||
constructor(public full: string) {
|
constructor(public full: string) {
|
||||||
const splits = full.split('.');
|
const [major, minor, ...rest] = full.split('.');
|
||||||
this.major = splits[0];
|
this.major = major;
|
||||||
this.minor = splits[1];
|
this.minor = minor;
|
||||||
this.patch = splits.slice(2).join('.');
|
this.patch = rest.join('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,10 +236,10 @@ export class Version {
|
||||||
public readonly patch: string;
|
public readonly patch: string;
|
||||||
|
|
||||||
constructor(public full: string) {
|
constructor(public full: string) {
|
||||||
const splits = full.split('.');
|
const [major, minor, ...rest] = full.split('.');
|
||||||
this.major = splits[0];
|
this.major = major;
|
||||||
this.minor = splits[1];
|
this.minor = minor;
|
||||||
this.patch = splits.slice(2).join('.');
|
this.patch = rest.join('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,10 @@ export class Version {
|
||||||
public readonly patch: string;
|
public readonly patch: string;
|
||||||
|
|
||||||
constructor(public full: string) {
|
constructor(public full: string) {
|
||||||
this.major = full.split('.')[0];
|
const [major, minor, ...rest] = full.split('.');
|
||||||
this.minor = full.split('.')[1];
|
this.major = major;
|
||||||
this.patch = full.split('.').slice(2).join('.');
|
this.minor = minor;
|
||||||
|
this.patch = rest.join('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue