Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- `arr.reduce`が空配列に対して初期値なしで呼び出された時、正式にエラーを出すよう
- `str.pad_start`,`str.pad_end`を追加
- `arr.insert`,`arr.remove`を追加
- `arr.sort`の処理を非同期的にして高速化

# 0.18.0
- `Core:abort`でプログラムを緊急停止できるように
Expand Down
5 changes: 3 additions & 2 deletions src/interpreter/primitive-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ const PRIMITIVE_PROPS: {
const mergeSort = async (arr: Value[], comp: VFn): Promise<Value[]> => {
if (arr.length <= 1) return arr;
const mid = Math.floor(arr.length / 2);
const left = await mergeSort(arr.slice(0, mid), comp);
const right = await mergeSort(arr.slice(mid), comp);
const left_promise = mergeSort(arr.slice(0, mid), comp);
const right_promise = mergeSort(arr.slice(mid), comp);
const [left, right] = await Promise.all([left_promise, right_promise]);
return merge(left, right, comp);
};
const merge = async (left: Value[], right: Value[], comp: VFn): Promise<Value[]> => {
Expand Down