mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-05 03:55:58 +01:00
Improve legibility of CertificationSet code
This commit is contained in:
parent
41f4e3c453
commit
f27f1133f7
1 changed files with 6 additions and 9 deletions
|
@ -90,26 +90,23 @@ class CertificationSet(
|
|||
require(issuer.fingerprint == certification.issuer.fingerprint) { "Issuer fingerprint mismatch." }
|
||||
require(target.fingerprint == certification.target.fingerprint) { "Target fingerprint mismatch." }
|
||||
|
||||
var certificationsForUserId: MutableList<Certification>? = _certifications[certification.userId]
|
||||
if (certificationsForUserId == null) {
|
||||
certificationsForUserId = ArrayList()
|
||||
_certifications[certification.userId] = certificationsForUserId
|
||||
}
|
||||
|
||||
val certificationsForUserId = _certifications.getOrPut(certification.userId) { mutableListOf() }
|
||||
if (certificationsForUserId.isEmpty()) {
|
||||
certificationsForUserId.add(certification)
|
||||
return
|
||||
}
|
||||
|
||||
val existing = certificationsForUserId[0]
|
||||
// if existing is older than this certification
|
||||
if (existing.creationTime.before(certification.creationTime)) {
|
||||
certificationsForUserId.clear() // throw away older certifications
|
||||
// throw away older certifications
|
||||
certificationsForUserId.clear()
|
||||
}
|
||||
// If our certification is newest
|
||||
// If this certification is newest (or equally old!)
|
||||
if (!existing.creationTime.after(certification.creationTime)) {
|
||||
certificationsForUserId.add(certification)
|
||||
}
|
||||
// else this certification is older, so ignore
|
||||
// else this certification is older, so don't add it
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
|
|
Loading…
Reference in a new issue