From 6a00886804c53883d919f008f6ec47a574d86607 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Mon, 24 Jul 2017 19:52:24 +0500 Subject: 2017-07-24 --- src/world/Section.cpp | 55 +++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src/world/Section.cpp') diff --git a/src/world/Section.cpp b/src/world/Section.cpp index 279d2b2..ff2a4fb 100644 --- a/src/world/Section.cpp +++ b/src/world/Section.cpp @@ -47,28 +47,28 @@ void Section::Parse() { endswap(&longArray[i]); std::vector blocks; blocks.reserve(4096); - { - auto begin = std::chrono::steady_clock::now(); - int bitPos = 0; - unsigned short t = 0; - for (size_t i = 0; i < m_dataBlocksLen; i++) { - for (int j = 0; j < 8; j++) { - t |= (m_dataBlocks[i] & 0x01) ? 0x80 : 0x00; - t >>= 1; - m_dataBlocks[i] >>= 1; - bitPos++; - if (bitPos >= m_bitsPerBlock) { - bitPos = 0; - t >>= m_bitsPerBlock - 1; - blocks.push_back(t); - t = 0; - } - } - } - auto end = std::chrono::steady_clock::now(); - std::chrono::duration time = end - begin; - totalParsingTime += time.count(); - } + { + auto begin = std::chrono::steady_clock::now(); + int bitPos = 0; + unsigned short t = 0; + for (size_t i = 0; i < m_dataBlocksLen; i++) { + for (int j = 0; j < 8; j++) { + t |= (m_dataBlocks[i] & 0x01) ? 0x80 : 0x00; + t >>= 1; + m_dataBlocks[i] >>= 1; + bitPos++; + if (bitPos >= m_bitsPerBlock) { + bitPos = 0; + t >>= m_bitsPerBlock - 1; + blocks.push_back(t); + t = 0; + } + } + } + auto end = std::chrono::steady_clock::now(); + std::chrono::duration time = end - begin; + totalParsingTime += time.count(); + } std::vector light; light.reserve(4096); for (int i = 0; i < 2048; i++) { @@ -137,8 +137,11 @@ Vector Section::GetPosition() { } size_t Section::GetHash() { - if (m_blocks.empty()) - return 0; - std::string str((unsigned char*)m_blocks.data(), (unsigned char*)m_blocks.data() + m_blocks.size() * sizeof(Block)); - return std::hash{}(str); + if (m_blocks.empty()) return 0; + + unsigned char *from = reinterpret_cast(m_blocks.data()); + size_t length = m_blocks.size() * sizeof(Block); + + std::string str(from, from + length); + return std::hash{}(str); } \ No newline at end of file -- cgit v1.2.3