playframework / play-json

The Play JSON library
Apache License 2.0
361 stars 133 forks source link

try to avoid reparsing numbers as BigDecimal when serializing #1073

Closed pjfanning closed 2 months ago

pjfanning commented 2 months ago

Pull Request Checklist

Fixes

Fixes #xxxx

Purpose

What does this PR do?

Parsing numbers from strings is expensive. This PR covers one case where a BigDecimal is converted to a String (expensive too) and then parsed again as a BigDecimal. This PR skips the final parse and just uses the BigDecimal instance that we already have.

Background Context

Why did you take this approach?

References

Are there any relevant issues / PRs / mailing lists discussions?