improved decoding speed by inlining x_isError() functions

This commit is contained in:
Yann Collet 2016-05-12 15:55:26 +02:00
parent 16871680e3
commit ccd6e86d45
3 changed files with 27 additions and 18 deletions

View File

@ -64,6 +64,7 @@
/* ************************************************************** /* **************************************************************
* Error Management * Error Management
****************************************************************/ ****************************************************************/
#define FSE_isError ERR_isError
#define FSE_STATIC_ASSERT(c) { enum { FSE_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ #define FSE_STATIC_ASSERT(c) { enum { FSE_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */

View File

@ -30,7 +30,7 @@
*/ */
/* ************************************* /*-*************************************
* Dependencies * Dependencies
***************************************/ ***************************************/
#include <stdlib.h> #include <stdlib.h>
@ -43,6 +43,12 @@
#include "huf.h" /* declaration of HUF_isError, HUF_getErrorName */ #include "huf.h" /* declaration of HUF_isError, HUF_getErrorName */
/*-****************************************
* Version
******************************************/
unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; }
/*-**************************************** /*-****************************************
* ZSTD Error Management * ZSTD Error Management
******************************************/ ******************************************/
@ -50,16 +56,16 @@
* tells if a return value is an error code */ * tells if a return value is an error code */
unsigned ZSTD_isError(size_t code) { return ERR_isError(code); } unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
/*! ZSTD_getErrorName() :
* provides error code string from function result (useful for debugging) */
const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
/*! ZSTD_getError() : /*! ZSTD_getError() :
* convert a `size_t` function result into a proper ZSTD_errorCode enum */ * convert a `size_t` function result into a proper ZSTD_errorCode enum */
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); } ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
/*! ZSTD_getErrorName() : /*! ZSTD_getErrorString() :
* provides error code string (useful for debugging) */ * provides error code string from enum */
const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
/*! ZSTD_getErrorName() :
* provides error code string (useful for debugging) */
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); } const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); }
@ -88,7 +94,7 @@ const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(error
/*-************************************************************** /*-**************************************************************
* FSE NCount encoding-decoding * FSE NCount decoding
****************************************************************/ ****************************************************************/
static short FSE_abs(short a) { return a<0 ? -a : a; } static short FSE_abs(short a) { return a<0 ? -a : a; }
@ -175,7 +181,7 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t
ip = iend - 4; ip = iend - 4;
} }
bitStream = MEM_readLE32(ip) >> (bitCount & 31); bitStream = MEM_readLE32(ip) >> (bitCount & 31);
} } } } /* while ((remaining>1) && (charnum<=*maxSVPtr)) */
if (remaining != 1) return ERROR(GENERIC); if (remaining != 1) return ERROR(GENERIC);
*maxSVPtr = charnum-1; *maxSVPtr = charnum-1;

View File

@ -83,18 +83,20 @@
#endif #endif
/*-*************************************
* Macros
***************************************/
#define ZSTD_isError ERR_isError /* for inlining */
#define FSE_isError ERR_isError
#define HUF_isError ERR_isError
/*_******************************************************* /*_*******************************************************
* Memory operations * Memory operations
**********************************************************/ **********************************************************/
static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); } static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); }
/*-*************************************
* Error Management
***************************************/
unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; }
/*-************************************************************* /*-*************************************************************
* Context management * Context management
***************************************************************/ ***************************************************************/