Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/coding
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2018-12-24 17:47:34 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2018-12-26 08:38:51 +0300
commitf66f24b477f3d1b57ff6e1461604cb462300efbd (patch)
tree02e3515a9e6c1f04b00f0f6d4b5003d0919e591b /coding
parent8206a2edc7b31feede301cd01a231e2b9611f6a1 (diff)
[coding] Cleaned up some unused code.
Diffstat (limited to 'coding')
-rw-r--r--coding/CMakeLists.txt6
-rw-r--r--coding/coder.hpp5
-rw-r--r--coding/coder_util.hpp30
-rw-r--r--coding/coding_tests/CMakeLists.txt2
-rw-r--r--coding/coding_tests/coder_test.hpp20
-rw-r--r--coding/coding_tests/coder_util_test.cpp31
-rw-r--r--coding/diff.hpp20
-rw-r--r--coding/diff_patch_common.hpp13
-rw-r--r--coding/matrix_traversal.hpp6
-rw-r--r--coding/polymorph_reader.hpp41
-rw-r--r--coding/varint_misc.hpp99
11 files changed, 12 insertions, 261 deletions
diff --git a/coding/CMakeLists.txt b/coding/CMakeLists.txt
index c7fbe99724..8ed056315a 100644
--- a/coding/CMakeLists.txt
+++ b/coding/CMakeLists.txt
@@ -18,8 +18,6 @@ set(
buffer_reader.hpp
bwt_coder.hpp
byte_stream.hpp
- coder.hpp
- coder_util.hpp
compressed_bit_vector.cpp
compressed_bit_vector.hpp
constants.hpp
@@ -27,7 +25,6 @@ set(
csv_reader.hpp
dd_vector.hpp
diff.hpp
- diff_patch_common.hpp
elias_coder.hpp
endianness.hpp
file_container.cpp
@@ -50,14 +47,12 @@ set(
internal/file_data.cpp
internal/file_data.hpp
internal/xmlparser.hpp
- matrix_traversal.hpp
memory_region.hpp
mmap_reader.cpp
mmap_reader.hpp
parse_xml.hpp
point_coding.cpp
point_coding.hpp
- polymorph_reader.hpp
read_write_utils.hpp
reader.cpp
reader.hpp
@@ -92,7 +87,6 @@ set(
var_record_reader.hpp
var_serial_vector.hpp
varint.hpp
- varint_misc.hpp
# varint_vector.cpp
# varint_vector.hpp
write_to_sink.hpp
diff --git a/coding/coder.hpp b/coding/coder.hpp
deleted file mode 100644
index f45d09c1bd..0000000000
--- a/coding/coder.hpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-#include "base/exception.hpp"
-
-DECLARE_EXCEPTION(StringCodingException, RootException);
-DECLARE_EXCEPTION(DstOutOfMemoryStringCodingException, StringCodingException);
diff --git a/coding/coder_util.hpp b/coding/coder_util.hpp
deleted file mode 100644
index a29c88a65c..0000000000
--- a/coding/coder_util.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-#include "coding/coder.hpp"
-#include "base/base.hpp"
-#include "base/exception.hpp"
-#include "std/string.hpp"
-
-template <typename FixedSizeCoderT, typename SrcCharT>
-void FixedDstSizeCodeToString(FixedSizeCoderT coder, SrcCharT * pSrc, size_t srcSize, string & dst)
-{
- dst.resize(1024);
- while (true)
- {
- size_t dstUsed = coder(pSrc, srcSize, &dst[0], dst.size());
- if (dstUsed != -1)
- {
- dst.resize(dstUsed);
- return;
- }
- else
- {
- // Double dst string size.
- try { dst.resize(dst.size() * 2); }
- catch (std::exception & e)
- {
- dst.clear();
- MYTHROW(DstOutOfMemoryStringCodingException, (e.what()));
- }
- }
- }
-}
diff --git a/coding/coding_tests/CMakeLists.txt b/coding/coding_tests/CMakeLists.txt
index 86d6ab7cbb..729c46b0fa 100644
--- a/coding/coding_tests/CMakeLists.txt
+++ b/coding/coding_tests/CMakeLists.txt
@@ -5,8 +5,6 @@ set(
base64_test.cpp
bit_streams_test.cpp
bwt_coder_tests.cpp
- coder_test.hpp
- coder_util_test.cpp
compressed_bit_vector_test.cpp
csv_reader_test.cpp
dd_vector_test.cpp
diff --git a/coding/coding_tests/coder_test.hpp b/coding/coding_tests/coder_test.hpp
deleted file mode 100644
index 3f72a5e0e1..0000000000
--- a/coding/coding_tests/coder_test.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include "testing/testing.hpp"
-#include "coding/coder.hpp"
-
-// TODO: void CoderRandomTest(Coder & encoder, Coder & decoder);
-// TODO: void CoderTextTest(Coder & encoder, Coder & decoder);
-// TODO: Test buffer overrun coder behavior.
-
-template <typename EncoderT, typename DecoderT>
-void CoderAaaaTest(EncoderT encoder, DecoderT decoder)
-{
- for (int i = 1; i <= 65536; (i > 16 && (i & 3) == 1) ? i = (i & ~3) * 2 : ++i)
- {
- string data(i, 'a'), encoded, decoded;
- encoder(&data[0], data.size(), encoded);
- decoder(&encoded[0], encoded.size(), decoded);
- TEST_EQUAL(data, decoded, ());
- }
-}
diff --git a/coding/coding_tests/coder_util_test.cpp b/coding/coding_tests/coder_util_test.cpp
deleted file mode 100644
index ff693e3009..0000000000
--- a/coding/coding_tests/coder_util_test.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "testing/testing.hpp"
-
-#include "coding/coder_util.hpp"
-#include "base/logging.hpp"
-
-//namespace
-//{
-// size_t FixedDstSizeInfiniteMemoryEncode(char const *, size_t, char *, size_t /*dstSize*/)
-// {
-// // LOG(LINFO, ("DstSize", dstSize));
-// return -1U;
-// }
-//}
-
-/* Commented because takes too much time after memory upgrage :)
-UNIT_TEST(FixedDstSizeCodeToStringInfiniteMemoryTest)
-{
- bool thrownDstOutOfMemoryStringCodingException = false;
- try
- {
- char const src [] = "Test";
- string dst;
- FixedDstSizeCodeToString(&FixedDstSizeInfiniteMemoryEncode, src, 4, dst);
- }
- catch (DstOutOfMemoryStringCodingException & e)
- {
- thrownDstOutOfMemoryStringCodingException = true;
- }
- TEST(thrownDstOutOfMemoryStringCodingException, ());
-}
-*/
diff --git a/coding/diff.hpp b/coding/diff.hpp
index 91e7c55432..9468f3c118 100644
--- a/coding/diff.hpp
+++ b/coding/diff.hpp
@@ -1,5 +1,4 @@
#pragma once
-#include "coding/diff_patch_common.hpp"
#include "base/assert.hpp"
#include "base/base.hpp"
@@ -11,6 +10,12 @@
namespace diff
{
+enum Operation
+{
+ OPERATION_COPY = 0,
+ OPERATION_DELETE = 1,
+ OPERATION_INSERT = 2,
+};
template <class PatchWriterT, typename SizeT = uint64_t> class PatchCoder
{
@@ -18,27 +23,27 @@ public:
typedef SizeT size_type;
explicit PatchCoder(PatchWriterT & patchWriter)
- : m_LastOperation(COPY), m_LastOpCode(0), m_PatchWriter(patchWriter)
+ : m_LastOperation(OPERATION_COPY), m_LastOpCode(0), m_PatchWriter(patchWriter)
{
}
void Delete(size_type n)
{
if (n != 0)
- Op(DELETE, n);
+ Op(OPERATION_DELETE, n);
}
void Copy(size_type n)
{
if (n != 0)
- Op(COPY, n);
+ Op(OPERATION_COPY, n);
}
template <typename TIter> void Insert(TIter it, size_type n)
{
if (n != 0)
{
- Op(INSERT, n);
+ Op(OPERATION_INSERT, n);
m_PatchWriter.WriteData(it, n);
}
}
@@ -66,7 +71,7 @@ private:
if (m_LastOpCode != 0)
m_PatchWriter.WriteOperation(m_LastOpCode);
else
- CHECK_EQUAL(m_LastOperation, COPY, ()); // "We were just initialized."
+ CHECK_EQUAL(m_LastOperation, OPERATION_COPY, ()); // "We were just initialized."
}
Operation m_LastOperation;
@@ -211,5 +216,4 @@ private:
HasherT m_Hasher;
size_t m_BlockSize;
};
-
-}
+} // namespace diff
diff --git a/coding/diff_patch_common.hpp b/coding/diff_patch_common.hpp
deleted file mode 100644
index 061a576d0c..0000000000
--- a/coding/diff_patch_common.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#pragma once
-
-namespace diff
-{
-
-enum Operation
-{
- COPY = 0,
- DELETE = 1,
- INSERT = 2,
-};
-
-}
diff --git a/coding/matrix_traversal.hpp b/coding/matrix_traversal.hpp
deleted file mode 100644
index 8ac53207ca..0000000000
--- a/coding/matrix_traversal.hpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-template <typename T> T TraverseMatrixInRowOrder(T n, T i, T j, bool is_back)
-{
- return (i * n + j) * 2 + (is_back ? 1 : 0);
-}
diff --git a/coding/polymorph_reader.hpp b/coding/polymorph_reader.hpp
deleted file mode 100644
index 0277a359c9..0000000000
--- a/coding/polymorph_reader.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#pragma once
-#include "coding/reader.hpp"
-#include "std/unique_ptr.hpp"
-
-class PolymorphReader
-{
-public:
- // Takes ownership of pReader
- explicit PolymorphReader(Reader const * pReader = 0) : m_pReader(pReader)
- {
- }
-
- PolymorphReader(PolymorphReader const & reader)
- : m_pReader(reader.m_pReader->CreateSubReader(0, reader.m_pReader->Size()))
- {
- }
-
- PolymorphReader & operator = (PolymorphReader const & reader)
- {
- PolymorphReader(reader).m_pReader.swap(m_pReader);
- return *this;
- }
-
- inline uint64_t Size() const
- {
- return m_pReader->Size();
- }
-
- inline void Read(uint64_t pos, void * p, size_t size) const
- {
- m_pReader->Read(pos, p, size);
- }
-
- inline PolymorphReader SubReader(uint64_t pos, uint64_t size) const
- {
- return PolymorphReader(m_pReader->CreateSubReader(pos, size));
- }
-
-private:
- unique_ptr<Reader const> m_pReader;
-};
diff --git a/coding/varint_misc.hpp b/coding/varint_misc.hpp
deleted file mode 100644
index a727adcbf6..0000000000
--- a/coding/varint_misc.hpp
+++ /dev/null
@@ -1,99 +0,0 @@
-// Author: Artyom Polkovnikov.
-// Different variants of Varint encoding/decoding.
-
-#pragma once
-
-#include "coding/reader.hpp"
-#include "coding/writer.hpp"
-
-#include "base/assert.hpp"
-#include "std/cstdint.hpp"
-#include "std/vector.hpp"
-
-// Encode Varint by appending to vector of bytes.
-inline void VarintEncode(vector<uint8_t> & dst, uint64_t n)
-{
- if (n == 0)
- {
- dst.push_back(0);
- }
- else
- {
- while (n != 0)
- {
- uint8_t b = n & 0x7F;
- n >>= 7;
- b |= n == 0 ? 0 : 0x80;
- dst.push_back(b);
- }
- }
-}
-// Encode varint using bytes Writer.
-inline void VarintEncode(Writer & writer, uint64_t n)
-{
- if (n == 0)
- {
- writer.Write(&n, 1);
- }
- else
- {
- while (n != 0)
- {
- uint8_t b = n & 0x7F;
- n >>= 7;
- b |= n == 0 ? 0 : 0x80;
- writer.Write(&b, 1);
- }
- }
-}
-// Deocde varint at given pointer and offset, offset is incremented after encoding.
-inline uint64_t VarintDecode(void * src, uint64_t & offset)
-{
- uint64_t n = 0;
- int shift = 0;
- while (1)
- {
- uint8_t b = *(((uint8_t*)src) + offset);
- CHECK_LESS_OR_EQUAL(shift, 56, ());
- n |= uint64_t(b & 0x7F) << shift;
- ++offset;
- if ((b & 0x80) == 0) break;
- shift += 7;
- }
- return n;
-}
-// Decode varint using bytes Reader, offset is incremented after decoding.
-inline uint64_t VarintDecode(Reader & reader, uint64_t & offset)
-{
- uint64_t n = 0;
- int shift = 0;
- while (1)
- {
- uint8_t b = 0;
- reader.Read(offset, &b, 1);
- CHECK_LESS_OR_EQUAL(shift, 56, ());
- n |= uint64_t(b & 0x7F) << shift;
- ++offset;
- if ((b & 0x80) == 0) break;
- shift += 7;
- }
- return n;
-}
-// Reverse decode varint. Offset should point to last byte of decoded varint.
-// It is compulsory that there is at least one encoded varint before this varint.
-// After decoding offset points to the last byte of previous varint.
-inline uint64_t VarintDecodeReverse(Reader & reader, uint64_t & offset)
-{
- uint8_t b = 0;
- do
- {
- --offset;
- reader.Read(offset, &b, 1);
- }
- while ((b & 0x80) != 0);
- uint64_t prevLastEncodedByteOffset = offset;
- ++offset;
- uint64_t num = VarintDecode(reader, offset);
- offset = prevLastEncodedByteOffset;
- return num;
-}