mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Convert receiver to parameter
This commit is contained in:
parent
46ec2460b3
commit
44598aa1fa
@ -120,23 +120,23 @@ internal object SemVersionInternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun SemVersion.compareInternal(other: SemVersion): Int {
|
fun compareInternal(source: SemVersion, other: SemVersion): Int {
|
||||||
// ignored metadata in comparing
|
// ignored metadata in comparing
|
||||||
|
|
||||||
// If $this equals $other (without metadata),
|
// If $this equals $other (without metadata),
|
||||||
// return same.
|
// return same.
|
||||||
if (other.mainVersion.contentEquals(mainVersion) && identifier == other.identifier) {
|
if (other.mainVersion.contentEquals(source.mainVersion) && source.identifier == other.identifier) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
fun IntArray.getSafe(index: Int) = getOrElse(index) { 0 }
|
fun IntArray.getSafe(index: Int) = getOrElse(index) { 0 }
|
||||||
|
|
||||||
// Compare main-version
|
// Compare main-version
|
||||||
for (index in 0 until (max(mainVersion.size, other.mainVersion.size))) {
|
for (index in 0 until (max(source.mainVersion.size, other.mainVersion.size))) {
|
||||||
val result = mainVersion.getSafe(index).compareTo(other.mainVersion.getSafe(index))
|
val result = source.mainVersion.getSafe(index).compareTo(other.mainVersion.getSafe(index))
|
||||||
if (result != 0) return result
|
if (result != 0) return result
|
||||||
}
|
}
|
||||||
// If main-versions are same.
|
// If main-versions are same.
|
||||||
var identifier0 = identifier
|
var identifier0 = source.identifier
|
||||||
var identifier1 = other.identifier
|
var identifier1 = other.identifier
|
||||||
// If anyone doesn't have the identifier...
|
// If anyone doesn't have the identifier...
|
||||||
if (identifier0 == null || identifier1 == null) {
|
if (identifier0 == null || identifier1 == null) {
|
||||||
|
@ -233,6 +233,6 @@ public data class SemVersion internal constructor(
|
|||||||
* if it's greater than [other].
|
* if it's greater than [other].
|
||||||
*/
|
*/
|
||||||
public override operator fun compareTo(other: SemVersion): Int {
|
public override operator fun compareTo(other: SemVersion): Int {
|
||||||
return SemVersionInternal.run { compareInternal(other) }
|
return SemVersionInternal.run { compareInternal(this@SemVersion, other) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user