Skip to content

Commit

Permalink
refactor: static Parser class
Browse files Browse the repository at this point in the history
Parser is thread-safe, so share it.
ua-parser/uap-java#44

response time 700ms -> 200ms
  • Loading branch information
ShanePark committed Feb 19, 2023
1 parent 1afab87 commit 2fc66c4
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ data class RefreshTokenDto(
) {

companion object {
private val parser = Parser()

fun of(userAgent: String?): UserAgent? {
if (userAgent == null) return null
val client = Parser().parse(userAgent)
val client = parser.parse(userAgent)
return UserAgent(
os = client.os.family,
browser = client.userAgent.family,
device = client.device.family,
)
}
}

}
}

0 comments on commit 2fc66c4

Please sign in to comment.