Skip to content

Commit

Permalink
refactor: use find as opposed to forEach to search a map
Browse files Browse the repository at this point in the history
  • Loading branch information
Ugo Amanoh committed Dec 17, 2019
1 parent 7ff682d commit 36c4831
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions core/src/main/java/me/uport/sdk/core/Networks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,8 @@ object Networks {
* Searches for an [EthNetwork] based on a [name]
*/
private fun getNetworkByName(name: String): EthNetwork? {
for ((_, value) in NETWORK_CONFIG) {
if (value.name.toLowerCase() == name.toLowerCase()) {
return value
}
}
return null
val queryName = name.toLowerCase()
return NETWORK_CONFIG.values.find { it.name.toLowerCase() == queryName }
}

private fun cleanId(id: String) = id.clean0xPrefix().trimStart('0').prepend0xPrefix()
Expand Down

0 comments on commit 36c4831

Please sign in to comment.