You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/07/03 04:02:25 UTC

[jira] [Resolved] (PDFBOX-1654) Wasted work in XMLUtil.getNodeValue

     [ https://issues.apache.org/jira/browse/PDFBOX-1654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Hewson resolved PDFBOX-1654.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0

I applied Fred's patch to the trunk in [r1607516|http://svn.apache.org/r1607516].

> Wasted work in XMLUtil.getNodeValue
> -----------------------------------
>
>                 Key: PDFBOX-1654
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1654
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.8.2
>         Environment: any
>            Reporter: Adrian Nistor
>              Labels: patch, performance
>             Fix For: 2.0.0
>
>         Attachments: XMLUtil-addPlus.patch, patch.diff, patchShort.diff
>
>
> The problem appears in version 1.8.2 and in revision 1497941.  I
> attached a two-line patch (patch.diff) that fixes it.
> In method "XMLUtil.getNodeValue", the loop over "children" keeps
> overriding "retval" with "next.getNodeValue()".  Therefore, only the
> last written value is visible out of the loop and all the other writes
> and iterations are not necessary.  The patch iterates from the end of
> "children" and breaks the first time when "retval" is set.
> The above fix (in patch.diff) is certainly correct (it's easy to see
> through code inspection), but I think we can have an even shorter
> patch (one line, in patchShort.diff): just break as soon as "retval"
> is set, without reversion the loop order.  patchShort.diff is correct
> only if there can be only one "Text" child, or if it doesn't matter
> which "Text" child is returned (the last, like in the original code,
> or the first, like in patchShort.diff).



--
This message was sent by Atlassian JIRA
(v6.2#6252)