Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff61527939 | ||
|
|
7ff578f89b | ||
|
|
27da03e8db |
@@ -16,11 +16,16 @@ open class EcoConfig(
|
||||
private val values = ConcurrentHashMap<String, Any?>()
|
||||
|
||||
@Transient
|
||||
var injections = ConcurrentHashMap<String, InjectablePlaceholder>()
|
||||
private val injections = mutableMapOf<String, InjectablePlaceholder>()
|
||||
|
||||
fun init(values: Map<String, Any?>) {
|
||||
@Transient
|
||||
private var injectionHash = 0
|
||||
|
||||
fun init(values: Map<String, Any?>, injections: Map<String, InjectablePlaceholder>) {
|
||||
this.values.clear()
|
||||
this.values.putAll(values.normalizeToConfig(this.type))
|
||||
|
||||
this.addInjectablePlaceholder(injections.values)
|
||||
}
|
||||
|
||||
override fun toPlaintext(): String {
|
||||
@@ -179,6 +184,7 @@ open class EcoConfig(
|
||||
override fun addInjectablePlaceholder(placeholders: Iterable<InjectablePlaceholder>) {
|
||||
for (placeholder in placeholders) {
|
||||
injections[placeholder.pattern.pattern()] = placeholder
|
||||
injectionHash = injectionHash xor placeholder.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +194,7 @@ open class EcoConfig(
|
||||
|
||||
override fun clearInjectedPlaceholders() {
|
||||
injections.clear()
|
||||
injectionHash = 0 // Reset the hash
|
||||
}
|
||||
|
||||
override fun toMap(): MutableMap<String, Any?> {
|
||||
@@ -239,18 +246,6 @@ open class EcoConfig(
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
/*
|
||||
The keys are completely redundant, as they are only used to prevent
|
||||
duplicate keys in the map. Therefore, we can ignore them and just
|
||||
hash the actual placeholder values.
|
||||
*/
|
||||
|
||||
var injectionHash = 0
|
||||
|
||||
injections.forEachValue(5) {
|
||||
injectionHash = injectionHash xor (it.hashCode() shl 5)
|
||||
}
|
||||
|
||||
// hashCode() has to compute extremely quickly, so we're using bitwise, because why not?
|
||||
// Fucking filthy to use identityHashCode here, but it should be extremely fast
|
||||
val identityHash = System.identityHashCode(this)
|
||||
|
||||
@@ -10,7 +10,6 @@ class EcoConfigSection(
|
||||
injections: Map<String, InjectablePlaceholder> = emptyMap()
|
||||
) : EcoConfig(type) {
|
||||
init {
|
||||
this.init(values)
|
||||
this.injections = ConcurrentHashMap(injections)
|
||||
this.init(values, injections)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ open class EcoLoadableConfig(
|
||||
protected fun init(reader: Reader) {
|
||||
val string = reader.readToString()
|
||||
makeHeader(string)
|
||||
super.init(type.toMap(string))
|
||||
super.init(type.toMap(string), emptyMap())
|
||||
}
|
||||
|
||||
fun init(file: File) {
|
||||
|
||||
@@ -50,7 +50,7 @@ open class EcoUpdatableConfig(
|
||||
val reader = BufferedReader(InputStreamReader(newIn, StandardCharsets.UTF_8))
|
||||
|
||||
val config = EcoConfigSection(type, emptyMap())
|
||||
config.init(type.toMap(reader.readToString()))
|
||||
config.init(type.toMap(reader.readToString()), emptyMap())
|
||||
return config
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.65.2
|
||||
version = 6.65.3
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user