diff --git a/CMakeLists.txt b/CMakeLists.txt index ae62e59..07adee6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,13 @@ cmake_minimum_required(VERSION 2.8) project(mstch) option (WITH_UNIT_TESTS "enable building unit test executable" OFF) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3") + +set(CMAKE_BUILD_TYPE Release) + +if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O3") +endif() + add_subdirectory(src) if(WITH_UNIT_TESTS) enable_testing() diff --git a/include/mstch/mstch.hpp b/include/mstch/mstch.hpp index 4c677f5..6847528 100644 --- a/include/mstch/mstch.hpp +++ b/include/mstch/mstch.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -20,7 +21,7 @@ class object_t { } bool has(const std::string name) const { - return methods.count(name); + return methods.count(name) != 0; } protected: diff --git a/src/render_context.cpp b/src/render_context.cpp index 18d7b99..89ab657 100644 --- a/src/render_context.cpp +++ b/src/render_context.cpp @@ -25,7 +25,7 @@ std::string render_context::push::render(const template_type& templt) { render_context::render_context( const mstch::node& node, const std::map& partials): - partials{partials}, nodes{node} + partials(partials), nodes(1, node) { state.push(std::unique_ptr(new outside_section)); } diff --git a/src/template_type.cpp b/src/template_type.cpp index 355c4f6..b3da2c5 100644 --- a/src/template_type.cpp +++ b/src/template_type.cpp @@ -23,7 +23,7 @@ void template_type::tokenize(const std::string& tmp) { citer beg = tmp.begin(); auto npos = std::string::npos; - for (unsigned long cur_pos = 0; cur_pos < tmp.size();) { + for (unsigned long long cur_pos = 0; cur_pos < tmp.size();) { auto open_pos = tmp.find(open, cur_pos); auto close_pos = tmp.find( close, open_pos == npos ? open_pos : open_pos + 1); diff --git a/test/benchmark_main.cpp b/test/benchmark_main.cpp index 82f7adb..d551a5b 100644 --- a/test/benchmark_main.cpp +++ b/test/benchmark_main.cpp @@ -3,9 +3,9 @@ #include #include -unsigned long current_msec() { - return std::chrono::system_clock::now().time_since_epoch() / - std::chrono::milliseconds(1); +unsigned long long current_msec() { + return std::chrono::time_point_cast( + std::chrono::system_clock::now()).time_since_epoch().count(); } int main() { @@ -25,7 +25,7 @@ int main() { }} }; - std::vector times; + std::vector times; for (int j = 0; j < 10; j++) { auto start = current_msec(); for (int i = 0; i < 5000; i++)