From 6191c69d743f32a89abb62e73c39e4d1ed6d6dd5 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Mon, 7 Oct 2019 15:16:38 +0200 Subject: [PATCH] move to hash algorithm defined since C++11 for calculating checksums. dynare#1661 --- src/DynamicModel.cc | 14 +++----------- src/DynamicModel.hh | 5 ----- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index f095c3b6..4b555a28 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -6580,8 +6580,6 @@ DynamicModel::dynamicOnlyEquationsNbr() const bool DynamicModel::isChecksumMatching(const string &basename, bool block) const { - boost::crc_32_type result; - std::stringstream buffer; // Write equation tags @@ -6634,13 +6632,7 @@ DynamicModel::isChecksumMatching(const string &basename, bool block) const } } - const size_t private_buffer_size{1024}; - char private_buffer[private_buffer_size]; - while (buffer) - { - buffer.get(private_buffer, private_buffer_size); - result.process_bytes(private_buffer, strlen(private_buffer)); - } + unsigned int result = hash<string>{}(buffer.str()); bool basename_dir_exists = !filesystem::create_directory(basename); @@ -6660,7 +6652,7 @@ DynamicModel::isChecksumMatching(const string &basename, bool block) const } } // write new checksum file if none or different from old checksum - if (old_checksum != result.checksum()) + if (old_checksum != result) { checksum_file.open(filename, ios::out | ios::binary); if (!checksum_file.is_open()) @@ -6668,7 +6660,7 @@ DynamicModel::isChecksumMatching(const string &basename, bool block) const cerr << "ERROR: Can't open file " << filename << endl; exit(EXIT_FAILURE); } - checksum_file << result.checksum(); + checksum_file << result; checksum_file.close(); return false; } diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index f3f2a41f..92323bee 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -25,11 +25,6 @@ using namespace std; #include <fstream> #include <filesystem> -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" -#include <boost/crc.hpp> -#pragma GCC diagnostic pop - #include "StaticModel.hh" //! Stores a dynamic model -- GitLab