Skip to content

Commit

Permalink
Avoid unnecessary casts on ConfigCursor#asObjectCursor
Browse files Browse the repository at this point in the history
This avoids unnecessary casts on the `asObjectCursor` method of `ConfigCursor`
by creating an already specialized cursor if we're using a `ConfigObjectSource`.
  • Loading branch information
jcazevedo committed Nov 4, 2019
1 parent a9e77dc commit 9e27a4b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/scala/pureconfig/ConfigSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ final class ConfigObjectSource private (getConf: () => Result[Config]) extends C
def value(): Result[ConfigObject] =
config().right.flatMap(_.resolveSafe()).right.map(_.root)

// Avoids unnecessary cast on `ConfigCursor#asObjectCursor`.
override def cursor(): Result[ConfigCursor] =
value().right.map(ConfigObjectCursor(_, Nil))

/**
* Reads a `Config` from this config source. The returned config is usually unresolved, unless
* the source forces it otherwise.
Expand Down

0 comments on commit 9e27a4b

Please sign in to comment.