Skip to content

Commit 6130be2

Browse files
committed
Some clang-tidy suggested fixes for C++11
1 parent 969dd42 commit 6130be2

File tree

7 files changed

+14
-12
lines changed

7 files changed

+14
-12
lines changed

src/Index.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct IndexHandler : IndexSink {
120120
IndexHandler(Log &log, std::unique_ptr<LineIndexer> indexer) :
121121
log(log), indexer(std::move(indexer)), currentLine(0) {}
122122

123-
virtual ~IndexHandler() {}
123+
~IndexHandler() override = default;
124124

125125
bool onLine(uint64_t lineNumber, const char *line, size_t length) {
126126
try {

src/IndexSink.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// to the IndexSink's add method.
99
class IndexSink {
1010
public:
11-
virtual ~IndexSink() { }
11+
virtual ~IndexSink() = default;
1212

1313
// Add a key to be indexed. offset should be the offset within the line.
1414
virtual void add(StringView item, size_t offset) = 0;

src/LineIndexer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class IndexSink;
1010
// matches within it (based on whatever it indexes, e.g. a matching RegExp).
1111
class LineIndexer {
1212
public:
13-
virtual ~LineIndexer() { }
13+
virtual ~LineIndexer() = default;
1414

1515
virtual void index(IndexSink &sink, StringView line) = 0;
16-
};
16+
};

src/LineSink.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// A sink to be called with each line in a file.
66
class LineSink {
77
public:
8-
virtual ~LineSink() { }
8+
virtual ~LineSink() = default;
99

1010
virtual bool onLine(
1111
size_t lineNumber,

src/Log.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// CaptureLog.
88
class Log {
99
public:
10-
virtual ~Log() { }
10+
virtual ~Log() = default;
1111

1212
enum class Severity {
1313
Debug, Info, Warning, Error

src/RangeFetcher.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RangeFetcher {
1616
// A handler for line ranges.
1717
class Handler {
1818
public:
19-
virtual ~Handler() { }
19+
virtual ~Handler() = default;
2020

2121
// Called for each line within a group.
2222
virtual void onLine(uint64_t line) = 0;

src/zq.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <iostream>
99
#include <stdexcept>
10+
#include <utility>
1011
#include "RangeFetcher.h"
1112

1213
using namespace std;
@@ -17,7 +18,7 @@ namespace {
1718
struct PrintSink : LineSink {
1819
bool printLineNum;
1920

20-
PrintSink(bool printLineNum) : printLineNum(printLineNum) { }
21+
explicit PrintSink(bool printLineNum) : printLineNum(printLineNum) { }
2122

2223
bool onLine(size_t l, size_t, const char *line, size_t length) override {
2324
if (printLineNum) cout << l << ":";
@@ -33,14 +34,15 @@ struct PrintHandler : RangeFetcher::Handler {
3334
const std::string sep;
3435

3536
PrintHandler(Index &index, LineSink &sink, bool printSep,
36-
const std::string &sep)
37-
: index(index), sink(sink), printSep(printSep), sep(sep) { }
37+
std::string sep)
38+
: index(index), sink(sink), printSep(printSep),
39+
sep(std::move(sep)) { }
3840

39-
virtual void onLine(uint64_t line) override {
41+
void onLine(uint64_t line) override {
4042
index.getLine(line, sink);
4143
}
4244

43-
virtual void onSeparator() override {
45+
void onSeparator() override {
4446
if (printSep)
4547
cout << sep << endl;
4648
}

0 commit comments

Comments
 (0)