Skip to content

Commit

Permalink
Fixed #4285 - Locale performance updates with large datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Aug 17, 2023
1 parent 961ba35 commit 99d7761
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/lib/calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2589,7 +2589,7 @@ export default {
let innerHTML = '';
if (this.responsiveOptions) {
let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * o1.breakpoint.localeCompare(o2.breakpoint, undefined, { numeric: true }));
let responsiveOptions = [...this.responsiveOptions].filter((o) => !!(o.breakpoint && o.numMonths)).sort((o1, o2) => -1 * new Intl.Collator(undefined, { numeric: true }).compare(o1.breakpoint, o2.breakpoint));
for (let i = 0; i < responsiveOptions.length; i++) {
let { breakpoint, numMonths } = responsiveOptions[i];
Expand Down
2 changes: 1 addition & 1 deletion components/lib/carousel/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export default {
if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true });
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return -1 * result;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dataview/DataView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default {
if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true });
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return this.sortOrder * result;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/galleria/GalleriaThumbnails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export default {
if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true });
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return -1 * result;
Expand Down
5 changes: 3 additions & 2 deletions components/lib/treetable/TreeTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export default {
if (value1 == null && value2 != null) result = -1;
else if (value1 != null && value2 == null) result = 1;
else if (value1 == null && value2 == null) result = 0;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = value1.localeCompare(value2, undefined, { numeric: true });
else if (typeof value1 === 'string' && typeof value2 === 'string') result = new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return this.d_sortOrder * result;
Expand Down Expand Up @@ -458,7 +458,8 @@ export default {
if (value1 === value2) {
return this.d_multiSortMeta.length - 1 > index ? this.multisortField(node1, node2, index + 1) : 0;
} else {
if ((typeof value1 === 'string' || value1 instanceof String) && (typeof value2 === 'string' || value2 instanceof String)) return this.d_multiSortMeta[index].order * value1.localeCompare(value2, undefined, { numeric: true });
if ((typeof value1 === 'string' || value1 instanceof String) && (typeof value2 === 'string' || value2 instanceof String))
return this.d_multiSortMeta[index].order * new Intl.Collator(undefined, { numeric: true }).compare(value1, value2);
else result = value1 < value2 ? -1 : 1;
}
}
Expand Down

0 comments on commit 99d7761

Please sign in to comment.