diff --git a/Archive.cpp b/Archive.cpp index 200f6bd..70b3f6e 100644 --- a/Archive.cpp +++ b/Archive.cpp @@ -226,7 +226,7 @@ Filter* Archive::Algorithm::createFilter(Stream* stream, Analyzer* analyzer, Arc fout << s.Word() << std::endl; } } - auto& freq = builder.FrequencyCounter(); + auto& freq = builder.GetFrequencyCounter(); dict_filter->AddCodeWords(code_words.GetCodeWords(), code_words.num1_, code_words.num2_, code_words.num3_, &freq, dict_codes.Count()); if (false) { std::cerr << std::endl << "Before " << freq.Sum() << std::endl; diff --git a/CM-inl.hpp b/CM-inl.hpp index 01d6f2d..28968b9 100644 --- a/CM-inl.hpp +++ b/CM-inl.hpp @@ -126,7 +126,7 @@ inline void CM::init() { if (kInputs > idx++) binary_profile_.EnableModel(kModelSparse3); if (kInputs > idx++) binary_profile_.EnableModel(kModelSparse4); if (kInputs > idx++) binary_profile_.EnableModel(kModelOrder0); - if (kInputs > idx++) binary_profile_.EnableModel(static_cast(opts_[0])); + // if (kInputs > idx++) binary_profile_.EnableModel(static_cast(opts_[0])); // binary_profile_ = CMProfile(); binary_profile_.SetMatchModelOrder(binary_mm_order); binary_profile_.SetMinLZPLen(lzp_enabled_ ? 0 : kMaxMatch + 1); diff --git a/CM.hpp b/CM.hpp index 4720b00..eba3479 100644 --- a/CM.hpp +++ b/CM.hpp @@ -808,7 +808,7 @@ namespace cm { *(ctx_ptr++) = HashLookup(IntervalHash(hash) + interval_add, true); } if (cur.ModelEnabled(kModelInterval2, enabled)) { - *(ctx_ptr++) = HashLookup(hashify(interval_model2_ & interval2_mask_) + (22 * 123456781 + 1), true); + *(ctx_ptr++) = HashLookup(hashify(interval_model2_ & interval2_mask_) + (22 * 123456781ULL + 1), true); } if (cur.ModelEnabled(kModelBracket, enabled)) { auto hash = bracket_.GetHash(); @@ -822,7 +822,7 @@ namespace cm { static const size_t kCount = 1 << 16; int64_t total[kCount]; std::fill_n(total, kCount, -1); - return DPOptimalLeaves(cost, total, 0, 64); + return OptimalByteStates(cost, total, 0, 64); } int NextNibbleLeaf(int node, size_t next) { @@ -911,7 +911,7 @@ namespace cm { } } - uint32_t h = HashFunc((last_bytes_ & 0xFFFF) * 3, 0x4ec457c1 * 19); + uint32_t h = HashFunc((last_bytes_ & 0xFFFF) * 3, 0x4ec457c1ULL * 19); if (mm_len == 0) { ++miss_len_; if (kStatistics) { diff --git a/Dict.hpp b/Dict.hpp index ead178d..9895c5e 100644 --- a/Dict.hpp +++ b/Dict.hpp @@ -212,7 +212,7 @@ class Dict { words_.Clear(); } - FrequencyCounter<256>& FrequencyCounter() { + FrequencyCounter<256>& GetFrequencyCounter() { return counter_; } diff --git a/Util.hpp b/Util.hpp index 954404c..0c6793c 100644 --- a/Util.hpp +++ b/Util.hpp @@ -39,20 +39,31 @@ #define OVERRIDE -#ifdef WIN32 -#define ALWAYS_INLINE __forceinline -#define NO_INLINE __declspec(noinline) +#if defined(__GNUC__) && (__GNUC__ >= 4) +#define ALWAYS_INLINE __attribute__((__always_inline__)) inline +#define NO_INLINE __attribute__((__noinline__)) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) +# define ALWAYS_INLINE __forceinline +# if _MSC_VER >= 1310 +# define NO_INLINE __declspec(noinline) +# else +# define NO_INLINE +# endif #else -#define ALWAYS_INLINE __attribute__((always_inline)) -#define NO_INLINE __declspec(noinline) +# define ALWAYS_INLINE +# define NO_INLINE #endif #define no_alias __restrict #define rst // no_alias -// TODO: Implement these. -#define LIKELY(x) x -#define UNLIKELY(x) x +#if defined(__GNUC__) && (__GNUC__ >= 3) +#define LIKELY(x) __builtin_expect(!!(x), 1) +#define UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +#define LIKELY(x) !!(x) +#define UNLIKELY(x) !!(x) +#endif #ifdef _DEBUG static const bool kIsDebugBuild = true; @@ -60,10 +71,16 @@ static const bool kIsDebugBuild = true; static const bool kIsDebugBuild = false; #endif -#ifdef _MSC_VER -#define ASSUME(x) __assume(x) +#if defined(_MSC_VER) && (_MSC_VER >= 1310) +# define ASSUME(x) __assume(x) +#elif defined(__has_builtin) +# if __has_builtin(__builtin_assume) +# define ASSUME(x) __builtin_assume(x) +# else +# define ASSUME(x) +# endif #else -#define ASSUME(x) +# define ASSUME(x) #endif typedef uint32_t hash_t;