Skip to content

Commit c7fa9b5

Browse files
committed
Make entire implementation namespaces anonymous
1 parent 65148b1 commit c7fa9b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+122
-228
lines changed

src/arm64/bitmanipulation.h

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

4-
namespace simdjson {
5-
namespace arm64 {
64
namespace {
5+
namespace arm64 {
76

87
// We sometimes call trailing_zero on inputs that are zero,
98
// but the algorithms do not end up using the returned value.
@@ -65,8 +64,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
6564
#endif
6665
}
6766

68-
} // namespace {
6967
} // namespace arm64
70-
} // namespace simdjson
68+
} // namespace {
7169

7270
#endif // SIMDJSON_ARM64_BITMANIPULATION_H

src/arm64/bitmask.h

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

4-
namespace simdjson {
5-
namespace arm64 {
64
namespace {
5+
namespace arm64 {
76

87
//
98
// Perform a "cumulative bitwise xor," flipping bits each time a 1 is encountered.

src/arm64/dom_parser_implementation.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// Stage 1
77
//
8-
namespace simdjson {
8+
namespace {
99
namespace SIMDJSON_IMPLEMENTATION {
1010

1111
using namespace simd;
@@ -98,9 +98,8 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
9898
return is_third_byte ^ is_fourth_byte;
9999
}
100100

101-
} // namespace {
102101
} // namespace SIMDJSON_IMPLEMENTATION
103-
} // namespace simdjson
102+
} // namespace {
104103

105104
#include "generic/stage1/utf8_lookup4_algorithm.h"
106105
#include "generic/stage1/json_structural_indexer.h"
@@ -117,11 +116,9 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
117116
//
118117
// Implementation-specific overrides
119118
//
120-
namespace simdjson {
119+
namespace {
121120
namespace SIMDJSON_IMPLEMENTATION {
122-
123121
namespace stage1 {
124-
namespace {
125122

126123
really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
127124
// On ARM, we don't short-circuit this if there are no backslashes, because the branch gives us no
@@ -130,7 +127,6 @@ really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
130127
return find_escaped_branchless(backslash);
131128
}
132129

133-
} // namespace {
134130
} // namespace stage1
135131

136132
WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept {
@@ -171,6 +167,6 @@ WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, siz
171167
}
172168

173169
} // namespace SIMDJSON_IMPLEMENTATION
174-
} // namespace simdjson
170+
} // namespace {
175171

176172
#include "arm64/end_implementation.h"

src/arm64/implementation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "arm64/begin_implementation.h"
22
#include "arm64/dom_parser_implementation.h"
33

4-
namespace simdjson {
5-
namespace SIMDJSON_IMPLEMENTATION {
64
namespace {
5+
namespace SIMDJSON_IMPLEMENTATION {
76

87
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
98
size_t capacity,
@@ -17,8 +16,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
1716
return SUCCESS;
1817
}
1918

20-
} // namespace {
2119
} // namespace SIMDJSON_IMPLEMENTATION
22-
} // namespace simdjson
20+
} // namespace {
2321

2422
#include "arm64/end_implementation.h"

src/arm64/implementation.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "simdjson.h"
55
#include "isadetection.h"
66

7-
namespace simdjson {
8-
namespace arm64 {
97
namespace {
8+
namespace arm64 {
109

10+
using namespace simdjson;
1111
using namespace simdjson::dom;
1212

1313
class implementation final : public simdjson::implementation {
@@ -22,8 +22,7 @@ class implementation final : public simdjson::implementation {
2222
WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final;
2323
};
2424

25-
} // namespace {
2625
} // namespace arm64
27-
} // namespace simdjson
26+
} // namespace {
2827

2928
#endif // SIMDJSON_ARM64_IMPLEMENTATION_H

src/arm64/numberparsing.h

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

4-
namespace simdjson {
5-
namespace arm64 {
64
namespace {
5+
namespace arm64 {
76

87
// we don't have SSE, so let us use a scalar function
98
// credit: https://johnnylee-sde.github.io/Fast-numeric-string-to-int/
@@ -15,9 +14,8 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
1514
return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
1615
}
1716

18-
} // namespace {
1917
} // namespace arm64
20-
} // namespace simdjson
18+
} // namespace {
2119

2220
#define SWAR_NUMBER_PARSING
2321

src/arm64/simd.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
#include <type_traits>
88

99

10-
namespace simdjson {
11-
namespace arm64 {
1210
namespace {
11+
namespace arm64 {
1312
namespace simd {
1413

1514
#ifdef SIMDJSON_REGULAR_VISUAL_STUDIO
@@ -495,8 +494,7 @@ really_inline int8x16_t make_int8x16_t(int8_t x1, int8_t x2, int8_t x3, int8_
495494
}; // struct simd8x64<T>
496495

497496
} // namespace simd
498-
} // namespace {
499497
} // namespace arm64
500-
} // namespace simdjson
498+
} // namespace {
501499

502500
#endif // SIMDJSON_ARM64_SIMD_H

src/arm64/stringparsing.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
#include "arm64/simd.h"
66
#include "arm64/bitmanipulation.h"
77

8-
namespace simdjson {
9-
namespace arm64 {
108
namespace {
9+
namespace arm64 {
1110

1211
using namespace simd;
1312

@@ -44,9 +43,8 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
4443
};
4544
}
4645

47-
} // namespace {
4846
} // namespace arm64
49-
} // namespace simdjson
47+
} // namespace {
5048

5149
#include "generic/stage2/stringparsing.h"
5250

src/fallback/bitmanipulation.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
#include "simdjson.h"
55
#include <limits>
66

7-
namespace simdjson {
8-
namespace fallback {
97
namespace {
8+
namespace fallback {
109

1110
#if defined(_MSC_VER) && !defined(_M_ARM64) && !defined(_M_X64)
1211
static inline unsigned char _BitScanForward64(unsigned long* ret, uint64_t x) {
@@ -72,8 +71,7 @@ really_inline bool mul_overflow(uint64_t value1, uint64_t value2, uint64_t *resu
7271
return value2 > 0 && value1 > std::numeric_limits<uint64_t>::max() / value2;
7372
}
7473

75-
} // namespace {
7674
} // namespace fallback
77-
} // namespace simdjson
75+
} // namespace {
7876

7977
#endif // SIMDJSON_FALLBACK_BITMANIPULATION_H

src/fallback/dom_parser_implementation.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
//
88
#include "generic/stage1/find_next_document_index.h"
99

10-
namespace simdjson {
11-
namespace SIMDJSON_IMPLEMENTATION {
1210
namespace {
11+
namespace SIMDJSON_IMPLEMENTATION {
1312
namespace stage1 {
1413

1514
class structural_scanner {
@@ -308,9 +307,8 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
308307
return true;
309308
}
310309

311-
} // namespace {
312310
} // namespace SIMDJSON_IMPLEMENTATION
313-
} // namespace simdjson
311+
} // namespace {
314312

315313
//
316314
// Stage 2
@@ -319,7 +317,7 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
319317
#include "fallback/numberparsing.h"
320318
#include "generic/stage2/structural_parser.h"
321319

322-
namespace simdjson {
320+
namespace {
323321
namespace SIMDJSON_IMPLEMENTATION {
324322

325323
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
@@ -346,6 +344,6 @@ WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, siz
346344
}
347345

348346
} // namespace SIMDJSON_IMPLEMENTATION
349-
} // namespace simdjson
347+
} // namespace {
350348

351349
#include "fallback/end_implementation.h"

src/fallback/implementation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "fallback/begin_implementation.h"
22
#include "fallback/dom_parser_implementation.h"
33

4-
namespace simdjson {
5-
namespace SIMDJSON_IMPLEMENTATION {
64
namespace {
5+
namespace SIMDJSON_IMPLEMENTATION {
76

87
WARN_UNUSED error_code implementation::create_dom_parser_implementation(
98
size_t capacity,
@@ -17,8 +16,7 @@ WARN_UNUSED error_code implementation::create_dom_parser_implementation(
1716
return SUCCESS;
1817
}
1918

20-
} // namespace {
2119
} // namespace SIMDJSON_IMPLEMENTATION
22-
} // namespace simdjson
20+
} // namespace {
2321

2422
#include "fallback/end_implementation.h"

src/fallback/implementation.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "simdjson.h"
55
#include "isadetection.h"
66

7-
namespace simdjson {
8-
namespace fallback {
97
namespace {
8+
namespace fallback {
109

10+
using namespace simdjson;
1111
using namespace simdjson::dom;
1212

1313
class implementation final : public simdjson::implementation {
@@ -26,8 +26,7 @@ class implementation final : public simdjson::implementation {
2626
WARN_UNUSED bool validate_utf8(const char *buf, size_t len) const noexcept final;
2727
};
2828

29-
} // namespace {
3029
} // namespace fallback
31-
} // namespace simdjson
30+
} // namespace {
3231

3332
#endif // SIMDJSON_FALLBACK_IMPLEMENTATION_H

src/fallback/numberparsing.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ void found_unsigned_integer(uint64_t result, const uint8_t *buf);
88
void found_float(double result, const uint8_t *buf);
99
#endif
1010

11-
namespace simdjson {
12-
namespace SIMDJSON_IMPLEMENTATION {
1311
namespace {
12+
namespace SIMDJSON_IMPLEMENTATION {
1413
static really_inline uint32_t parse_eight_digits_unrolled(const char *chars) {
1514
uint32_t result = 0;
1615
for (int i=0;i<8;i++) {
@@ -22,9 +21,8 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
2221
return parse_eight_digits_unrolled((const char *)chars);
2322
}
2423

25-
} // namespace {
2624
} // namespace SIMDJSON_IMPLEMENTATION
27-
} // namespace simdjson
25+
} // namespace {
2826

2927
#define SWAR_NUMBER_PARSING
3028
#include "generic/stage2/numberparsing.h"

src/fallback/stringparsing.h

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

44
#include "simdjson.h"
55

6-
namespace simdjson {
7-
namespace fallback {
86
namespace {
7+
namespace fallback {
98

109
// Holds backslashes and quotes locations.
1110
struct backslash_and_quote {
@@ -27,9 +26,8 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
2726
return { src[0] };
2827
}
2928

30-
} // namespace {
3129
} // namespace fallback
32-
} // namespace simdjson
30+
} // namespace {
3331

3432
#include "generic/stage2/stringparsing.h"
3533

src/generic/dom_parser_implementation.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "simdjson.h"
22
#include "isadetection.h"
33

4-
namespace simdjson {
5-
namespace SIMDJSON_IMPLEMENTATION {
64
namespace {
5+
namespace SIMDJSON_IMPLEMENTATION {
76

87
// expectation: sizeof(scope_descriptor) = 64/8.
98
struct scope_descriptor {
@@ -45,16 +44,14 @@ class dom_parser_implementation final : public internal::dom_parser_implementati
4544
WARN_UNUSED error_code set_max_depth(size_t max_depth) noexcept final;
4645
};
4746

48-
} // namespace {
4947
} // namespace SIMDJSON_IMPLEMENTATION
50-
} // namespace simdjson
48+
} // namespace {
5149

5250
#include "generic/stage1/allocate.h"
5351
#include "generic/stage2/allocate.h"
5452

55-
namespace simdjson {
56-
namespace SIMDJSON_IMPLEMENTATION {
5753
namespace {
54+
namespace SIMDJSON_IMPLEMENTATION {
5855

5956
really_inline dom_parser_implementation::dom_parser_implementation() {}
6057

@@ -73,6 +70,5 @@ WARN_UNUSED error_code dom_parser_implementation::set_max_depth(size_t max_depth
7370
return SUCCESS;
7471
}
7572

76-
} // namespace {
7773
} // namespace SIMDJSON_IMPLEMENTATION
78-
} // namespace simdjson
74+
} // namespace {

src/generic/stage1/allocate.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace simdjson {
2-
namespace SIMDJSON_IMPLEMENTATION {
31
namespace {
2+
namespace SIMDJSON_IMPLEMENTATION {
43
namespace stage1 {
54
namespace allocate {
65

@@ -18,6 +17,5 @@ really_inline error_code set_capacity(internal::dom_parser_implementation &parse
1817

1918
} // namespace allocate
2019
} // namespace stage1
21-
} // namespace {
2220
} // namespace SIMDJSON_IMPLEMENTATION
23-
} // namespace simdjson
21+
} // namespace {

0 commit comments

Comments
 (0)