Skip to content

Commit 0d1c574

Browse files
authored
A few more changes... (simdjson#775)
* More nitpicking.
1 parent c564815 commit 0d1c574

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

benchmark/benchmarker.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const char* benchmark_stage_name(BenchmarkStage stage) {
241241

242242
struct benchmarker {
243243
// JSON text from loading the file. Owns the memory.
244-
padded_string json;
244+
padded_string json{};
245245
// JSON filename
246246
const char *filename;
247247
// Event collector that can be turned on to measure cycles, missed branches, etc.
@@ -251,15 +251,15 @@ struct benchmarker {
251251
// Loaded on first parse.
252252
json_stats* stats;
253253
// Speed and event summary for full parse (not including allocation)
254-
event_aggregate all_stages;
254+
event_aggregate all_stages{};
255255
// Speed and event summary for stage 1
256-
event_aggregate stage1;
256+
event_aggregate stage1{};
257257
// Speed and event summary for stage 2
258-
event_aggregate stage2;
258+
event_aggregate stage2{};
259259
// Speed and event summary for allocation
260-
event_aggregate allocate_stage;
260+
event_aggregate allocate_stage{};
261261
// Speed and event summary for the repeatly-parsing mode
262-
event_aggregate loop;
262+
event_aggregate loop{};
263263

264264
benchmarker(const char *_filename, event_collector& _collector)
265265
: filename(_filename), collector(_collector), stats(NULL) {
@@ -278,6 +278,9 @@ struct benchmarker {
278278
}
279279
}
280280

281+
benchmarker(const benchmarker&) = delete;
282+
benchmarker& operator=(const benchmarker&) = delete;
283+
281284
const event_aggregate& operator[](BenchmarkStage stage) const {
282285
switch (stage) {
283286
case BenchmarkStage::ALL: return this->all_stages;

benchmark/event_counter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ struct event_count {
8484

8585
struct event_aggregate {
8686
int iterations = 0;
87-
event_count total;
88-
event_count best;
89-
event_count worst;
87+
event_count total{};
88+
event_count best{};
89+
event_count worst{};
9090

9191
event_aggregate() {}
9292

@@ -111,8 +111,8 @@ struct event_aggregate {
111111
};
112112

113113
struct event_collector {
114-
event_count count;
115-
time_point<steady_clock> start_clock;
114+
event_count count{};
115+
time_point<steady_clock> start_clock{};
116116

117117
#if defined(__linux__)
118118
LinuxEvents<PERF_TYPE_HARDWARE> linux_events;
@@ -149,4 +149,4 @@ struct event_collector {
149149
}
150150
};
151151

152-
#endif
152+
#endif

benchmark/linux/linux-perf-events.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
template <int TYPE = PERF_TYPE_HARDWARE> class LinuxEvents {
1818
int fd;
1919
bool working;
20-
perf_event_attr attribs;
21-
size_t num_events;
22-
std::vector<uint64_t> temp_result_vec;
23-
std::vector<uint64_t> ids;
20+
perf_event_attr attribs{};
21+
size_t num_events{};
22+
std::vector<uint64_t> temp_result_vec{};
23+
std::vector<uint64_t> ids{};
2424

2525
public:
2626
explicit LinuxEvents(std::vector<int> config_vec) : fd(0), working(true) {

benchmark/parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void exit_usage(string message) {
7878
}
7979

8080
struct option_struct {
81-
vector<char*> files;
81+
vector<char*> files{};
8282
bool stage1_only = false;
8383

8484
int32_t iterations = 200;

include/simdjson/implementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class atomic_ptr {
214214
operator T*() { return ptr.load(); }
215215
T& operator*() { return *ptr; }
216216
T* operator->() { return ptr.load(); }
217-
T* operator=(T *_ptr) { return ptr = _ptr; }
217+
atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; }
218218

219219
private:
220220
std::atomic<T*> ptr;

tools/minify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void exit_usage(std::string message) {
3232

3333

3434
struct option_struct {
35-
char* filename;
35+
char* filename{};
3636

3737
option_struct(int argc, char **argv) {
3838
#ifndef _MSC_VER

0 commit comments

Comments
 (0)