poppler/JPEG2000Stream.cc | 49 ++++++++++++++++++++++++---------------------- poppler/JPEG2000Stream.h | 7 +----- 2 files changed, 28 insertions(+), 28 deletions(-)
New commits: commit 636faafcb84b856580398f7883b6406d645c85d1 Author: Adam Reichold <[email protected]> Date: Tue Jan 6 22:57:20 2015 +0100 JPEG2000Stream: Inline doGetChar and doLookChar diff --git a/poppler/JPEG2000Stream.cc b/poppler/JPEG2000Stream.cc index 2d48899..35e98b8 100644 --- a/poppler/JPEG2000Stream.cc +++ b/poppler/JPEG2000Stream.cc @@ -7,7 +7,8 @@ // Copyright 2008-2010, 2012 Albert Astals Cid <[email protected]> // Copyright 2011 Daniel Glöckner <[email protected]> // Copyright 2014 Thomas Freitag <[email protected]> -// Copyright 2013,2014 Adrian Johnson <[email protected]> +// Copyright 2013, 2014 Adrian Johnson <[email protected]> +// Copyright 2015 Adam Reichold <[email protected]> // // Licensed under GPLv2 or later // @@ -49,6 +50,22 @@ struct JPXStreamPrivate { #endif }; +static inline int doLookChar(JPXStreamPrivate* priv) { + if (unlikely(priv->counter >= priv->npixels)) + return EOF; + + return ((unsigned char *)priv->image->comps[priv->ccounter].data)[priv->counter]; +} + +static inline int doGetChar(JPXStreamPrivate* priv) { + const int result = doLookChar(priv); + if (++priv->ccounter == priv->ncomps) { + priv->ccounter = 0; + ++priv->counter; + } + return result; +} + JPXStream::JPXStream(Stream *strA) : FilterStream(strA) { priv = new JPXStreamPrivate; priv->inited = gFalse; @@ -91,8 +108,10 @@ Goffset JPXStream::getPos() { } int JPXStream::getChars(int nChars, Guchar *buffer) { + if (unlikely(priv->inited == gFalse)) { init(); } + for (int i = 0; i < nChars; ++i) { - const int c = doGetChar(); + const int c = doGetChar(priv); if (likely(c != EOF)) buffer[i] = c; else return i; } @@ -100,30 +119,15 @@ int JPXStream::getChars(int nChars, Guchar *buffer) { } int JPXStream::getChar() { - return doGetChar(); -} + if (unlikely(priv->inited == gFalse)) { init(); } -int JPXStream::doLookChar() { - if (unlikely(priv->inited == gFalse)) - init(); - - if (unlikely(priv->counter >= priv->npixels)) - return EOF; - - return ((unsigned char *)priv->image->comps[priv->ccounter].data)[priv->counter]; + return doGetChar(priv); } int JPXStream::lookChar() { - return doLookChar(); -} + if (unlikely(priv->inited == gFalse)) { init(); } -int JPXStream::doGetChar() { - int result = doLookChar(); - if (++priv->ccounter == priv->ncomps) { - priv->ccounter = 0; - ++priv->counter; - } - return result; + return doLookChar(priv); } GooString *JPXStream::getPSFilter(int psLevel, const char *indent) { @@ -135,8 +139,7 @@ GBool JPXStream::isBinary(GBool last) { } void JPXStream::getImageParams(int *bitsPerComponent, StreamColorSpaceMode *csMode) { - if (priv->inited == gFalse) - init(); + if (unlikely(priv->inited == gFalse)) { init(); } *bitsPerComponent = 8; if (priv->image && priv->image->numcomps == 3) diff --git a/poppler/JPEG2000Stream.h b/poppler/JPEG2000Stream.h index 50b7586..73b6bdd 100644 --- a/poppler/JPEG2000Stream.h +++ b/poppler/JPEG2000Stream.h @@ -6,7 +6,8 @@ // // Copyright 2008, 2010 Albert Astals Cid <[email protected]> // Copyright 2011 Daniel Glöckner <[email protected]> -// Copyright 2013,2014 Adrian Johnson <[email protected]> +// Copyright 2013, 2014 Adrian Johnson <[email protected]> +// Copyright 2015 Adam Reichold <[email protected]> // // Licensed under GPLv2 or later // @@ -49,10 +50,6 @@ private: void init(); virtual GBool hasGetChars() { return true; } virtual int getChars(int nChars, Guchar *buffer); - - int doGetChar(); - - int doLookChar(); }; #endif
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
