-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 性能优化 * 应用wasm target
- Loading branch information
Showing
13 changed files
with
120 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,29 @@ kotlin { | |
) | ||
} | ||
} | ||
wasmJs { | ||
browser { | ||
binaries.library() | ||
useCommonJs() | ||
} | ||
nodejs { | ||
binaries.library() | ||
useCommonJs() | ||
} | ||
applyBinaryen() | ||
compilations["main"].packageJson { | ||
name = "mahjong-utils-entry-wasm" | ||
customField( | ||
"author", mapOf( | ||
"name" to "ssttkkl", | ||
"email" to "[email protected]" | ||
) | ||
) | ||
customField( | ||
"license", "MIT" | ||
) | ||
} | ||
} | ||
|
||
val hostOs = System.getProperty("os.name") | ||
val isMingwX64 = hostOs.startsWith("Windows") | ||
|
@@ -65,6 +88,12 @@ kotlin { | |
val nativeTest by getting { | ||
dependsOn(nonJsTest) | ||
} | ||
val wasmJsMain by getting { | ||
dependsOn(nonJsMain) | ||
} | ||
val wasmJsTest by getting { | ||
dependsOn(nonJsTest) | ||
} | ||
} | ||
} | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
mahjong-utils/src/commonMain/kotlin/mahjongutils/common/BestHandPatternsSelector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mahjongutils.common | ||
|
||
import mahjongutils.models.hand.HandPattern | ||
|
||
internal class BestHandPatternsSelector<T : HandPattern>( | ||
private val calcShanten: (T) -> Int | ||
) { | ||
var bestShanten = 100 | ||
private set | ||
|
||
var bestPatterns = ArrayList<T>() | ||
private set | ||
|
||
fun receive(pattern: T) { | ||
val patShanten = calcShanten(pattern) | ||
if (patShanten < bestShanten) { | ||
bestShanten = patShanten | ||
bestPatterns = ArrayList() | ||
} | ||
if (patShanten == bestShanten) { | ||
bestPatterns.add(pattern) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
mahjong-utils/src/commonMain/kotlin/mahjongutils/yaku/CheckerFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters