diff --git a/benchmark/benchmarker.h b/benchmark/benchmarker.h index d93c2a45..471ba718 100644 --- a/benchmark/benchmarker.h +++ b/benchmark/benchmarker.h @@ -241,7 +241,7 @@ const char* benchmark_stage_name(BenchmarkStage stage) { struct benchmarker { // JSON text from loading the file. Owns the memory. - padded_string json; + padded_string json{}; // JSON filename const char *filename; // Event collector that can be turned on to measure cycles, missed branches, etc. @@ -251,15 +251,15 @@ struct benchmarker { // Loaded on first parse. json_stats* stats; // Speed and event summary for full parse (not including allocation) - event_aggregate all_stages; + event_aggregate all_stages{}; // Speed and event summary for stage 1 - event_aggregate stage1; + event_aggregate stage1{}; // Speed and event summary for stage 2 - event_aggregate stage2; + event_aggregate stage2{}; // Speed and event summary for allocation - event_aggregate allocate_stage; + event_aggregate allocate_stage{}; // Speed and event summary for the repeatly-parsing mode - event_aggregate loop; + event_aggregate loop{}; benchmarker(const char *_filename, event_collector& _collector) : filename(_filename), collector(_collector), stats(NULL) { @@ -278,6 +278,9 @@ struct benchmarker { } } + benchmarker(const benchmarker&) = delete; + benchmarker& operator=(const benchmarker&) = delete; + const event_aggregate& operator[](BenchmarkStage stage) const { switch (stage) { case BenchmarkStage::ALL: return this->all_stages; diff --git a/benchmark/event_counter.h b/benchmark/event_counter.h index 023d1be1..c10aa84a 100644 --- a/benchmark/event_counter.h +++ b/benchmark/event_counter.h @@ -84,9 +84,9 @@ struct event_count { struct event_aggregate { int iterations = 0; - event_count total; - event_count best; - event_count worst; + event_count total{}; + event_count best{}; + event_count worst{}; event_aggregate() {} @@ -111,8 +111,8 @@ struct event_aggregate { }; struct event_collector { - event_count count; - time_point start_clock; + event_count count{}; + time_point start_clock{}; #if defined(__linux__) LinuxEvents linux_events; @@ -149,4 +149,4 @@ struct event_collector { } }; -#endif \ No newline at end of file +#endif diff --git a/benchmark/linux/linux-perf-events.h b/benchmark/linux/linux-perf-events.h index 4c40eb04..0f411e0e 100644 --- a/benchmark/linux/linux-perf-events.h +++ b/benchmark/linux/linux-perf-events.h @@ -17,10 +17,10 @@ template class LinuxEvents { int fd; bool working; - perf_event_attr attribs; - size_t num_events; - std::vector temp_result_vec; - std::vector ids; + perf_event_attr attribs{}; + size_t num_events{}; + std::vector temp_result_vec{}; + std::vector ids{}; public: explicit LinuxEvents(std::vector config_vec) : fd(0), working(true) { diff --git a/benchmark/parse.cpp b/benchmark/parse.cpp index c933793f..ec6efc64 100644 --- a/benchmark/parse.cpp +++ b/benchmark/parse.cpp @@ -78,7 +78,7 @@ void exit_usage(string message) { } struct option_struct { - vector files; + vector files{}; bool stage1_only = false; int32_t iterations = 200; diff --git a/include/simdjson/implementation.h b/include/simdjson/implementation.h index 9eb8d60b..f0a32c32 100644 --- a/include/simdjson/implementation.h +++ b/include/simdjson/implementation.h @@ -214,7 +214,7 @@ public: operator T*() { return ptr.load(); } T& operator*() { return *ptr; } T* operator->() { return ptr.load(); } - T* operator=(T *_ptr) { return ptr = _ptr; } + atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; } private: std::atomic ptr; diff --git a/tools/minify.cpp b/tools/minify.cpp index 2748904e..d1c7118f 100644 --- a/tools/minify.cpp +++ b/tools/minify.cpp @@ -32,7 +32,7 @@ void exit_usage(std::string message) { struct option_struct { - char* filename; + char* filename{}; option_struct(int argc, char **argv) { #ifndef _MSC_VER