Skip to content

Commit

Permalink
减少不必要的重复加载
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer committed Feb 16, 2022
1 parent 13a6b49 commit ceceeef
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContentsLoader : Mod() {
override fun init() {
Events.on(ResetEvent::class.java) {
//fastPath
if (MyContentLoader.contents.all { it.content == it.lastContent }) {
if (MyContentLoader.contents.all { it.content eq it.lastContent }) {
MyContentLoader.contents.forEach { it.content = it.default }
return@on
}
Expand Down Expand Up @@ -45,6 +45,10 @@ class ContentsLoader : Mod() {

@Suppress("unused", "MemberVisibilityCanBePrivate")
companion object API {
infix fun ContentList.eq(contentList: ContentList?): Boolean {
return javaClass == contentList?.javaClass
}

fun maskChanged(type: ContentType) {
val c = MyContentLoader.contentMap[type] ?: throw IllegalArgumentException("Not Support Overwrite ContentType")
c.maskChanged()
Expand Down

0 comments on commit ceceeef

Please sign in to comment.