use Intl.Collator over String.prototype.localeCompare for better performance
This commit is contained in:
parent
c6c1e09cae
commit
d7a5547d80
11 changed files with 49 additions and 27 deletions
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { TagID } from "../../models";
|
||||
import { IAlgorithm } from "./IAlgorithm";
|
||||
import { compare } from "../../../../utils/strings";
|
||||
|
||||
/**
|
||||
* Sorts rooms according to the browser's determination of alphabetic.
|
||||
|
@ -24,7 +25,7 @@ import { IAlgorithm } from "./IAlgorithm";
|
|||
export class AlphabeticAlgorithm implements IAlgorithm {
|
||||
public async sortRooms(rooms: Room[], tagId: TagID): Promise<Room[]> {
|
||||
return rooms.sort((a, b) => {
|
||||
return a.name.localeCompare(b.name);
|
||||
return compare(a.name, b.name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
|||
import { SettingLevel } from "../../settings/SettingLevel";
|
||||
import { arrayFastClone } from "../../utils/arrays";
|
||||
import { UPDATE_EVENT } from "../AsyncStore";
|
||||
import { compare } from "../../utils/strings";
|
||||
|
||||
export const WIDGET_LAYOUT_EVENT_TYPE = "io.element.widgets.layout";
|
||||
|
||||
|
@ -240,7 +241,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
|||
|
||||
if (orderA === orderB) {
|
||||
// We just need a tiebreak
|
||||
return a.id.localeCompare(b.id);
|
||||
return compare(a.id, b.id);
|
||||
}
|
||||
|
||||
return orderA - orderB;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue