From: Philip Pronin Date: Thu, 23 Jan 2014 23:20:09 +0000 (-0800) Subject: CHECK EliasFanoCompressedList::encode input is sorted X-Git-Tag: v0.22.0~724 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3ac402b1e087ac8e3abe24b5f0a19f74fb3ddd11;p=folly.git 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 --- 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);