Skip to content

Commit

Permalink
Prefer HashMap over Map
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii committed Aug 16, 2024
1 parent 3808995 commit 1bfb93e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.http.codec

import scala.collection.immutable.ListMap
import scala.collection.immutable.{HashMap, ListMap}

import zio._

Expand All @@ -19,7 +19,11 @@ final case class HttpContentCodec[A](
choices: ListMap[MediaType, BinaryCodecWithSchema[A]],
) { self =>

private var lookupCache: Map[MediaType, Option[BinaryCodecWithSchema[A]]] = Map.empty
/**
* Uses an `HashMap` instead of a `Map` to avoid allocation of an Option when
* calling `.getOrElse`
*/
private var lookupCache: HashMap[MediaType, Option[BinaryCodecWithSchema[A]]] = HashMap.empty

/**
* A right biased merge of two HttpContentCodecs.
Expand Down

0 comments on commit 1bfb93e

Please sign in to comment.