<commit_before>/******************************************************************************
 *
 * Project:  integrating laszip into liblas - http://liblas.org -
 * Purpose:
 * Author:   <NAME>
 *           isenburg at cs.unc.edu
 *
 ******************************************************************************
 * Copyright (c) 2010, <NAME>
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Licence as published
 * by the Free Software Foundation.
 *
 * See the COPYING file for more information.
 *
 ****************************************************************************/

#ifndef MYDEFS_H
#define MYDEFS_H

typedef int                I32;
typedef short              I16;
typedef char               I8;

typedef unsigned int       U32;
typedef unsigned short     U16;
typedef unsigned char      U8;

#if defined(WIN32)            // 64 byte integer under Windows 
typedef unsigned __int64   U64;
typedef __int64            I64;
#else                          // 64 byte integer elsewhere ... 
typedef unsigned long long U64;
typedef long long          I64;
#endif

typedef float              F32;
typedef double             F64;

typedef bool               BOOL;

typedef union U32F32 { U32 u32; F32 f32; } U32F32;
typedef union U64F64 { U64 u64; F64 f64; } U64F64;
typedef union I32F32 { I32 i32; F32 f32; } I32F32;
typedef union I64F64 { I64 i64; F64 f64; } I64F64;

#define F32_MAX            +1.0e+30f
#define F32_MIN            -1.0e+30f

#define U8_MAX             0xFF // 255
#define U8_MAX_PLUS_ONE    0x0100 // 256

#define U16_MAX            0xFFFF // 65535
#define U16_MAX_PLUS_ONE   0x00010000 // 65536

#define U32_MAX            0xFFFFFFFF // 4294967295
#if defined(WIN32)            // 64 byte unsigned int constant under Windows 
#define U32_MAX_PLUS_ONE   0x0000000100000000 // 4294967296
#else                         // 64 byte unsigned int constant elsewhere ... 
#define U32_MAX_PLUS_ONE   0x0000000100000000ull // 4294967296
#endif

#define I8_MIN             0x80 // -128
#define I8_MAX             0x7F // 127

#define I16_MIN            0x8000 // -32768
#define I16_MAX            0x7FFF // 32767

#define I32_MIN            0x80000000 // -2147483648
#define I32_MAX            0x7FFFFFFF //  2147483647

#ifndef FALSE
#define FALSE   0
#endif

#ifndef TRUE
#define TRUE    1
#endif

#ifndef NULL
#define NULL    0
#endif

inline BOOL IS_LITTLE_ENDIAN()
{
  U32 i = 1;
  if (*((U8*)&i) == 1)
    return TRUE;
  else
    return FALSE;
}

inline void ENDIAN_SWAP_16(U8* field)
{
  U8 help = field[0];
  field[0] = field[1];
  field[1] = help;
}

inline void ENDIAN_SWAP_32(U8* field)
{
  U8 help;
  help = field[0];
  field[0] = field[3];
  field[3] = help;
  help = field[1];
  field[1] = field[2];
  field[2] = help;
}

inline void ENDIAN_SWAP_64(U8* field)
{
  U8 help;
  help = field[0];
  field[0] = field[7];
  field[7] = help;
  help = field[1];
  field[1] = field[6];
  field[6] = help;
  help = field[2];
  field[2] = field[5];
  field[5] = help;
  help = field[3];
  field[3] = field[4];
  field[4] = help;
}

inline void ENDIAN_SWAP_16(U8* from, U8* to)
{
  to[0] = from[1];
  to[1] = from[0];
}

inline void ENDIAN_SWAP_32(U8* from, U8* to)
{
  to[0] = from[3];
  to[1] = from[2];
  to[2] = from[1];
  to[3] = from[0];
}

inline void ENDIAN_SWAP_64(U8* from, U8* to)
{
  to[0] = from[7];
  to[1] = from[6];
  to[2] = from[5];
  to[3] = from[4];
  to[4] = from[3];
  to[5] = from[2];
  to[6] = from[1];
  to[7] = from[0];
}

#endif
<commit_msg>more efficient big endian handling<commit_after>/******************************************************************************
 *
 * Project:  integrating laszip into liblas - http://liblas.org -
 * Purpose:
 * Author:   <NAME>
 *           isenburg at cs.unc.edu
 *
 ******************************************************************************
 * Copyright (c) 2010, <NAME>
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Licence as published
 * by the Free Software Foundation.
 *
 * See the COPYING file for more information.
 *
 ****************************************************************************/

#ifndef MYDEFS_H
#define MYDEFS_H

typedef int                I32;
typedef short              I16;
typedef char               I8;

typedef unsigned int       U32;
typedef unsigned short     U16;
typedef unsigned char      U8;

#if defined(_WIN32)            // 64 byte integer under Windows 
typedef unsigned __int64   U64;
typedef __int64            I64;
#else                          // 64 byte integer elsewhere ... 
typedef unsigned long long U64;
typedef long long          I64;
#endif

typedef float              F32;
typedef double             F64;

#if defined(_WIN32)
typedef int                BOOL;
#else
typedef bool               BOOL;
#endif

typedef union U32F32 { U32 u32; F32 f32; } U32F32;
typedef union U64F64 { U64 u64; F64 f64; } U64F64;
typedef union I32F32 { I32 i32; F32 f32; } I32F32;
typedef union I64F64 { I64 i64; F64 f64; } I64F64;

#define F32_MAX            +1.0e+30f
#define F32_MIN            -1.0e+30f

#define U8_MAX             0xFF // 255
#define U8_MAX_PLUS_ONE    0x0100 // 256

#define U16_MAX            0xFFFF // 65535
#define U16_MAX_PLUS_ONE   0x00010000 // 65536

#define U32_MAX            0xFFFFFFFF // 4294967295
#if defined(WIN32)            // 64 byte unsigned int constant under Windows 
#define U32_MAX_PLUS_ONE   0x0000000100000000 // 4294967296
#else                         // 64 byte unsigned int constant elsewhere ... 
#define U32_MAX_PLUS_ONE   0x0000000100000000ull // 4294967296
#endif

#define I8_MIN             0x80 // -128
#define I8_MAX             0x7F // 127

#define I16_MIN            0x8000 // -32768
#define I16_MAX            0x7FFF // 32767

#define I32_MIN            0x80000000 // -2147483648
#define I32_MAX            0x7FFFFFFF //  2147483647

#ifndef FALSE
#define FALSE   0
#endif

#ifndef TRUE
#define TRUE    1
#endif

#ifndef NULL
#define NULL    0
#endif

inline BOOL IS_LITTLE_ENDIAN()
{
  const U32 i = 1;
  return (*((U8*)&i) == 1);
}

#define ENDIANSWAP16(n) \
	( ((((U16) n) << 8) & 0xFF00) | \
	  ((((U16) n) >> 8) & 0x00FF) )

#define ENDIANSWAP32(n) \
	( ((((U32) n) << 24) & 0xFF000000) |	\
	  ((((U32) n) <<  8) & 0x00FF0000) |	\
	  ((((U32) n) >>  8) & 0x0000FF00) |	\
	  ((((U32) n) >> 24) & 0x000000FF) )

inline void ENDIAN_SWAP_16(U8* field)
{
  U8 help = field[0];
  field[0] = field[1];
  field[1] = help;
}

inline void ENDIAN_SWAP_32(U8* field)
{
  U8 help;
  help = field[0];
  field[0] = field[3];
  field[3] = help;
  help = field[1];
  field[1] = field[2];
  field[2] = help;
}

inline void ENDIAN_SWAP_64(U8* field)
{
  U8 help;
  help = field[0];
  field[0] = field[7];
  field[7] = help;
  help = field[1];
  field[1] = field[6];
  field[6] = help;
  help = field[2];
  field[2] = field[5];
  field[5] = help;
  help = field[3];
  field[3] = field[4];
  field[4] = help;
}

inline void ENDIAN_SWAP_16(const U8* from, U8* to)
{
  to[0] = from[1];
  to[1] = from[0];
}

inline void ENDIAN_SWAP_32(const U8* from, U8* to)
{
  to[0] = from[3];
  to[1] = from[2];
  to[2] = from[1];
  to[3] = from[0];
}

inline void ENDIAN_SWAP_64(const U8* from, U8* to)
{
  to[0] = from[7];
  to[1] = from[6];
  to[2] = from[5];
  to[3] = from[4];
  to[4] = from[3];
  to[5] = from[2];
  to[6] = from[1];
  to[7] = from[0];
}

#endif

{'fraction_non_alphanumeric': 0.17690899581589958, 'fraction_numerical': 0.10826359832635983, 'mean_word_length': 2.3800265134776843, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5473137', 'n_tokens_mistral': 3318, 'n_tokens_neox': 2761, 'n_words': 754}