From dev-return-62777-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Thu May 9 13:19:03 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id ED68D180784 for ; Thu, 9 May 2019 15:19:02 +0200 (CEST) Received: (qmail 53981 invoked by uid 500); 9 May 2019 13:19:02 -0000 Mailing-List: contact dev-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list dev@pdfbox.apache.org Received: (qmail 53970 invoked by uid 99); 9 May 2019 13:19:02 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 May 2019 13:19:02 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 91BD9E260C for ; Thu, 9 May 2019 13:19:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 775FD2581B for ; Thu, 9 May 2019 13:19:00 +0000 (UTC) Date: Thu, 9 May 2019 13:19:00 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: dev@pdfbox.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PDFBOX-4539) Cache CharsetDecoder MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PDFBOX-4539?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D168= 36373#comment-16836373 ]=20 ASF subversion and git services commented on PDFBOX-4539: --------------------------------------------------------- Commit 1859006 from Tilman Hausherr in branch 'pdfbox/branches/issue45' [ https://svn.apache.org/r1859006 ] PDFBOX-4539: don't construct new decoder each time, as suggested by Jonatha= n > Cache CharsetDecoder > -------------------- > > Key: PDFBOX-4539 > URL: https://issues.apache.org/jira/browse/PDFBOX-4539 > Project: PDFBox > Issue Type: Improvement > Components: Parsing > Affects Versions: 2.0.14 > Reporter: Jonathan > Priority: Minor > Labels: performance > Fix For: 2.0.16 > > > We were using PDFBox to parse and process a large number of PDFs, which c= ould potentially contains thousands of pages in total, so performance matte= red to us. > Thus, we'd like to suggest to cache the CharsetDecoder, which is currentl= y instantiated on each call of `isValidUTF8(byte[])`. > Our suggestion in BaseParser.java > {code:java} > private static final CharsetDecoder csUTF_8 =3D Charsets.UTF_8.newDecoder= (); > /** > * Returns true if a byte sequence is valid UTF-8. > */ > private boolean isValidUTF8(byte[] input) > { > try > { > csUTF_8.decode(ByteBuffer.wrap(input)); > return true; > } > catch (CharacterCodingException e) > { > return false; > } > } > {code} > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org For additional commands, e-mail: dev-help@pdfbox.apache.org