Skip to content

Commit

Permalink
chore(pub): Simplify deserializing dependencies
Browse files Browse the repository at this point in the history
The dependencies node itself is never a scalar, so the code can be
simplified.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 21, 2024
1 parent bd745c1 commit 5c27750
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions plugins/package-managers/pub/src/main/kotlin/Pubspec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ private object DependencyMapSerializer : KSerializer<Map<String, Dependency>> by
override fun deserialize(decoder: Decoder): Map<String, Dependency> {
val input = decoder.beginStructure(descriptor) as YamlInput

val result = when (val node = input.node) {
is YamlScalar -> emptyMap()
is YamlMap -> node.entries.asSequence().associateBy({ it.key.content }, { it.value.decodeDependency() })
else -> throw SerializationException("Unexpected YAML node type: ${node.javaClass.simpleName}.")
}
val result = input.node.yamlMap.entries.asSequence().associate { it.key.content to it.value.decodeDependency() }

input.endStructure(descriptor)

Expand Down

0 comments on commit 5c27750

Please sign in to comment.