From 3ac402b1e087ac8e3abe24b5f0a19f74fb3ddd11 Mon Sep 17 00:00:00 2001 From: Philip Pronin Date: Thu, 23 Jan 2014 15:20:09 -0800 Subject: [PATCH] CHECK EliasFanoCompressedList::encode input is sorted Test Plan: fbconfig -r folly/experimental/test && fbmake runtests_opt Reviewed By: chaoyc@fb.com FB internal diff: D1141124 --- folly/experimental/EliasFanoCoding.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/folly/experimental/EliasFanoCoding.h b/folly/experimental/EliasFanoCoding.h index 74955617..bac16589 100644 --- a/folly/experimental/EliasFanoCoding.h +++ b/folly/experimental/EliasFanoCoding.h @@ -1,5 +1,5 @@ /* - * Copyright 2013 Facebook, Inc. + * Copyright 2014 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,10 +103,13 @@ struct EliasFanoCompressedList { encode(list, list + size, result); } + // Range (begin, end) should be sorted. template static void encode(RandomAccessIterator begin, RandomAccessIterator end, EliasFanoCompressedList& result) { + CHECK(std::is_sorted(begin, end)); + auto list = begin; const size_t size = end - begin; @@ -115,8 +118,6 @@ struct EliasFanoCompressedList { return; } - DCHECK(std::is_sorted(list, list + size)); - const ValueType upperBound = list[size - 1]; uint8_t numLowerBits = defaultNumLowerBits(upperBound, size); -- 2.34.1