Skip to content

Commit 0cfddea

Browse files
committed
Drop Transparent_string_cmp in favor of std::less<>
1 parent fb9fc58 commit 0cfddea

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

‎src/java_symbols.hpp‎

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,10 @@
2121

2222
#include <iostream>
2323

24-
//! Allows comparison between string and string_view
25-
struct Transparent_string_cmp : std::less<std::string_view>
26-
{
27-
using is_transparent = void;
28-
};
29-
30-
using Transparent_string_view_set = std::set<std::string_view, Transparent_string_cmp>;
31-
using Transparent_string_map = std::map<std::string, std::string, Transparent_string_cmp>;
24+
using String_view_set = std::set<std::string_view, std::less<>>;
25+
using String_map = std::map<std::string, std::string, std::less<>>;
3226

33-
using Parameter_dict = std::map<std::string_view, std::vector<std::string_view>, Transparent_string_cmp>;
27+
using Parameter_dict = std::map<std::string_view, std::vector<std::string_view>, std::less<>>;
3428

3529
struct Named_regex : std::regex
3630
{
@@ -121,7 +115,7 @@ struct Mutex
121115
struct Parameters
122116
{
123117
std::vector<Named_regex> patterns_;
124-
Transparent_string_view_set names_;
118+
String_view_set names_;
125119
bool also_remove_annotations_ = false;
126120
bool in_place_ = false;
127121
bool strict_mode_ = false;
@@ -130,8 +124,8 @@ struct Parameters
130124
struct Strict_mode
131125
{
132126
std::atomic<bool> any_annotation_removed_ = false;
133-
Mutex<std::map<std::string_view, bool, Transparent_string_cmp>> patterns_matched_;
134-
Mutex<std::map<std::string_view, bool, Transparent_string_cmp>> names_matched_;
127+
Mutex<std::map<std::string_view, bool, std::less<>>> patterns_matched_;
128+
Mutex<std::map<std::string_view, bool, std::less<>>> names_matched_;
135129
Mutex<std::map<std::string_view, bool>> files_truncated_;
136130
};
137131

@@ -386,7 +380,7 @@ inline std::tuple<std::string_view, std::string> next_annotation(std::string_vie
386380
* @return The simple class name.
387381
*/
388382
inline bool name_matches(std::string_view name, std::span<const Named_regex> patterns,
389-
const Transparent_string_view_set& names, const Transparent_string_map& imported_names) noexcept
383+
const String_view_set& names, const String_map& imported_names) noexcept
390384
{
391385
auto simple_name = name;
392386

@@ -439,10 +433,10 @@ inline bool name_matches(std::string_view name, std::span<const Named_regex> pat
439433
* removed simple class names to the fully-qualified name as present in the
440434
* import statement.
441435
*/
442-
inline std::tuple<std::string, Transparent_string_map> remove_imports(
443-
std::string_view content, std::span<const Named_regex> patterns, const Transparent_string_view_set& names)
436+
inline std::tuple<std::string, String_map> remove_imports(
437+
std::string_view content, std::span<const Named_regex> patterns, const String_view_set& names)
444438
{
445-
auto result = std::tuple<std::string, Transparent_string_map>();
439+
auto result = std::tuple<std::string, String_map>();
446440
auto& [new_content, removed_classes] = result;
447441
new_content.reserve(content.size());
448442
auto position = std::ptrdiff_t(0);
@@ -457,7 +451,7 @@ inline std::tuple<std::string, Transparent_string_map> remove_imports(
457451
auto import_name = std::string();
458452
auto [symbol, end_pos] = next_symbol(content, next_position + 6);
459453

460-
const auto empty_set = Transparent_string_view_set();
454+
const auto empty_set = String_view_set();
461455
const auto* names_passed = &names;
462456

463457
bool is_static = false;
@@ -548,7 +542,7 @@ inline std::tuple<std::string, Transparent_string_map> remove_imports(
548542
* @return The resulting string with annotations removed.
549543
*/
550544
inline std::string remove_annotations(std::string_view content, std::span<const Named_regex> patterns,
551-
const Transparent_string_view_set& names, const Transparent_string_map& imported_names)
545+
const String_view_set& names, const String_map& imported_names)
552546
{
553547
auto position = std::ptrdiff_t(0);
554548
auto result = std::string();
@@ -674,7 +668,7 @@ catch (std::exception& ex)
674668

675669
////////////////////////////////////////////////////////////////////////////////
676670

677-
inline Parameter_dict parse_arguments(std::span<const char*> args, const Transparent_string_view_set& no_argument_flags)
671+
inline Parameter_dict parse_arguments(std::span<const char*> args, const String_view_set& no_argument_flags)
678672
{
679673
auto result = Parameter_dict();
680674

0 commit comments

Comments
 (0)