You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2023/05/02 05:52:00 UTC
[jira] [Commented] (PDFBOX-5579) Change COSFloat.value to primitive type, do not use BigDecimal if not necessary
[ https://issues.apache.org/jira/browse/PDFBOX-5579?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17718436#comment-17718436 ]
ASF subversion and git services commented on PDFBOX-5579:
---------------------------------------------------------
Commit 1909550 from lehmi@apache.org in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1909550 ]
PDFBOX-5579: fix test
> Change COSFloat.value to primitive type, do not use BigDecimal if not necessary
> -------------------------------------------------------------------------------
>
> Key: PDFBOX-5579
> URL: https://issues.apache.org/jira/browse/PDFBOX-5579
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 3.0.0 PDFBox
> Reporter: Axel Howind
> Assignee: Andreas Lehmkühler
> Priority: Minor
> Fix For: 3.0.0 PDFBox
>
> Attachments: change_value_to_final_float_(primitive)_and_optimize_string_formatting.patch
>
>
> Using the primitive type here uses both less memory and also reduces overhead because less boxing/unboxing needs to be done.
> I changed value from `private Float value` to `private final float`.
> I also changed the formatting code in two small details:
> # using BigDecimal is really just necessary, if the value is formatted to scientific notation. Since Float.toString() is called anyway, we can check for presence of an exponent ('E') and if none is found, return the already created string.
> # I removed the trimZeroes() method and let BigDecimal handle this so that the zeroes are removed before converting to a string.
> I left valueAsString to be computed lazily when the string representation is not already known in the constructor call. It would also be possible to make valueAsString final, but then it might be computed unnecessarily, if formatString() is never called on the instance.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org