Skip to content

Commit b370731

Browse files
committed
fix some warnings shown by my linter
- Mostly missing and unused headers
1 parent 344ec24 commit b370731

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
build
2+
build_debug
3+
build_script
4+
.cache

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ int main(void) {
2828

2929
if (from_chars_double)
3030
target_compile_definitions(benchmark PUBLIC FROM_CHARS_DOUBLE_SUPPORTED=1)
31-
endif()
31+
endif()

benchmarks/benchmark.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,35 @@
88
*/
99

1010
#ifndef __CYGWIN__
11-
#include "absl/strings/numbers.h"
1211
#include "absl/strings/str_cat.h"
1312
#endif
1413

1514
#include "dragonbox/dragonbox_to_chars.h"
1615
#include "ryu/ryu.h"
17-
1816
#include "double-conversion/double-conversion.h"
19-
#include "double-conversion/ieee.h"
2017

2118
#define IEEE_8087
2219
#include "benchutil.h"
2320
#include "cxxopts.hpp"
21+
2422
#if NETLIB_SUPPORTED
2523
#include "gdtoa.h"
2624
#endif
25+
2726
#include "grisu2.h"
2827
#include "random_generators.h"
29-
#include <algorithm>
28+
3029
#include <charconv>
31-
#include <chrono>
3230
#include <climits>
3331
#include <cmath>
34-
#include <cstdint>
3532
#include <cstdio>
3633
#include <cstdlib>
3734
#include <cstring>
38-
#include <ctype.h>
3935
#include <float.h>
4036
#include <fmt/format.h>
4137
#include <fstream>
42-
#include <iomanip>
4338
#include <iostream>
4439
#include <limits.h>
45-
#include <locale.h>
46-
#include <random>
47-
#include <sstream>
4840
#include <stdio.h>
4941
#include <string>
5042
#include <vector>
@@ -177,10 +169,10 @@ void fileload(const char *filename) {
177169
std::cerr << "can't open " << filename << std::endl;
178170
return;
179171
}
180-
std::string line;
172+
181173
std::vector<double> lines;
182174
lines.reserve(10000); // let us reserve plenty of memory.
183-
while (getline(inputfile, line)) {
175+
for (std::string line; getline(inputfile, line);) {
184176
try {
185177
lines.push_back(std::stod(line));
186178
} catch (...) {

benchmarks/benchutil.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef BENCHUTIL_H
22
#define BENCHUTIL_H
3+
34
#include <cfloat>
45
#include <cstdio>
5-
#include <chrono>
66

77
#if defined(__linux__) || (__APPLE__ && __aarch64__)
88
#define USING_COUNTERS
@@ -131,5 +131,6 @@ void pretty_print(std::vector<double> &lines, std::string name,
131131
printf("%8.2f Mfloat/s ", number_of_floats * 1000 / result.first);
132132
printf(" %8.2f ns/f \n", double(result.first) / number_of_floats);
133133
}
134+
134135
#endif
135-
#endif //// BENCHUTIL_H
136+
#endif //// BENCHUTIL_H

benchmarks/counters/event_counter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#ifndef _MSC_VER
66
#include <dirent.h>
77
#endif
8-
#include <cinttypes>
98

109
#include <cstring>
1110

benchmarks/counters/linux-perf-events.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88

99
#include <cerrno> // for errno
1010
#include <cstring> // for memset
11-
#include <stdexcept>
12-
13-
#include <iostream>
11+
#include <cstdint> // for uint32_t, uint64_t
12+
#include <string>
1413
#include <vector>
1514

1615
template <int TYPE = PERF_TYPE_HARDWARE> class LinuxEvents {
@@ -101,4 +100,4 @@ template <int TYPE = PERF_TYPE_HARDWARE> class LinuxEvents {
101100
private:
102101
void report_error(const std::string &) { working = false; }
103102
};
104-
#endif
103+
#endif

benchmarks/random_generators.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#ifndef RANDOM_GENERATORS_H
22
#define RANDOM_GENERATORS_H
33

4+
#include <array>
5+
#include <memory>
46
#include <random>
57
#include <iostream>
68

79
struct float_number_generator {
8-
virtual double new_float() { return 0; }
9-
virtual std::string describe() { return "abstract class"; }
10+
virtual double new_float() = 0;
11+
virtual std::string describe() = 0;
1012
};
1113

1214
struct uniform_generator : float_number_generator {
@@ -80,16 +82,20 @@ struct simple_int64 : float_number_generator {
8082
double new_float() override { return gen(); }
8183
};
8284

83-
std::vector<std::string> model_names = {"uniform", "one_over_rand32",
84-
"simple_uniform32", "simple_int32",
85-
"int_e_int", "simple_int64"};
86-
std::unique_ptr<float_number_generator>
85+
constexpr std::array<const char*, 6> model_names = {
86+
"uniform", "one_over_rand32",
87+
"simple_uniform32", "simple_int32",
88+
"int_e_int", "simple_int64"
89+
};
90+
91+
inline std::unique_ptr<float_number_generator>
8792
get_generator_by_name(std::string name) {
8893
std::cout << "available models (-m): ";
8994
for (std::string name : model_names) {
9095
std::cout << name << " ";
9196
}
9297
std::cout << std::endl;
98+
9399
// This is naive, but also not very important.
94100
if (name == "uniform") {
95101
return std::unique_ptr<float_number_generator>(new uniform_generator());
@@ -111,4 +117,4 @@ get_generator_by_name(std::string name) {
111117
return std::unique_ptr<float_number_generator>(new uniform_generator());
112118
}
113119

114-
#endif
120+
#endif

benchmarks/string_format.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#ifndef STRING_FORMAT_H
22
#define STRING_FORMAT_H
33

4-
#include <iostream>
4+
#include <limits>
55
#include <sstream>
6+
67
/**
78
* This will generate a string with exactly the number of digits
89
* that are required to always be able to recover the original
@@ -45,4 +46,4 @@ template <typename T> std::string accurate_to_string_concise(T d) {
4546
return answer;
4647
}
4748

48-
#endif
49+
#endif

dependencies/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ FetchContent_GetProperties(doubleconversion)
3434
FetchContent_MakeAvailable(doubleconversion)
3535

3636
#CPMAddPackage("gh:ulfjack/[email protected]")
37-
include(FetchContent)
3837
FetchContent_Declare(
3938
ryu
4039
GIT_REPOSITORY https://github.com/ulfjack/ryu

0 commit comments

Comments
 (0)