Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f600ae8

Browse files
authored
Use libc++ variant of string view and remove the FML variant. (#9737)
1 parent 564f53f commit f600ae8

18 files changed

+90
-890
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ FILE: ../../../flutter/fml/platform/win/native_library_win.cc
186186
FILE: ../../../flutter/fml/platform/win/paths_win.cc
187187
FILE: ../../../flutter/fml/platform/win/wstring_conversion.h
188188
FILE: ../../../flutter/fml/size.h
189-
FILE: ../../../flutter/fml/string_view.cc
190-
FILE: ../../../flutter/fml/string_view.h
191-
FILE: ../../../flutter/fml/string_view_unittest.cc
192189
FILE: ../../../flutter/fml/synchronization/atomic_object.h
193190
FILE: ../../../flutter/fml/synchronization/count_down_latch.cc
194191
FILE: ../../../flutter/fml/synchronization/count_down_latch.h

fml/BUILD.gn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ source_set("fml") {
5252
"paths.cc",
5353
"paths.h",
5454
"size.h",
55-
"string_view.cc",
56-
"string_view.h",
5755
"synchronization/atomic_object.h",
5856
"synchronization/count_down_latch.cc",
5957
"synchronization/count_down_latch.h",
@@ -206,7 +204,6 @@ executable("fml_unittests") {
206204
"message_unittests.cc",
207205
"paths_unittests.cc",
208206
"platform/darwin/string_range_sanitization_unittests.mm",
209-
"string_view_unittest.cc",
210207
"synchronization/count_down_latch_unittests.cc",
211208
"synchronization/semaphore_unittest.cc",
212209
"synchronization/thread_annotations_unittest.cc",

fml/base32.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
#include "flutter/fml/base32.h"
66

77
#include <limits>
8-
9-
#include "flutter/fml/macros.h"
8+
#include <string>
109

1110
namespace fml {
1211

1312
static constexpr char kEncoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
1413

15-
std::pair<bool, std::string> Base32Encode(StringView input) {
14+
std::pair<bool, std::string> Base32Encode(std::string_view input) {
1615
if (input.empty()) {
1716
return {true, ""};
1817
}

fml/base32.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
#ifndef FLUTTER_FML_BASE32_H_
66
#define FLUTTER_FML_BASE32_H_
77

8-
#include <string>
8+
#include <string_view>
99
#include <utility>
1010

11-
#include "flutter/fml/string_view.h"
12-
1311
namespace fml {
1412

15-
std::pair<bool, std::string> Base32Encode(StringView input);
13+
std::pair<bool, std::string> Base32Encode(std::string_view input);
1614

1715
} // namespace fml
1816

fml/command_line.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,27 @@ CommandLine& CommandLine::operator=(const CommandLine& from) = default;
3636

3737
CommandLine& CommandLine::operator=(CommandLine&& from) = default;
3838

39-
bool CommandLine::HasOption(StringView name, size_t* index) const {
40-
auto it = option_index_.find(name.ToString());
39+
bool CommandLine::HasOption(std::string_view name, size_t* index) const {
40+
auto it = option_index_.find(name.data());
4141
if (it == option_index_.end())
4242
return false;
4343
if (index)
4444
*index = it->second;
4545
return true;
4646
}
4747

48-
bool CommandLine::GetOptionValue(StringView name, std::string* value) const {
48+
bool CommandLine::GetOptionValue(std::string_view name,
49+
std::string* value) const {
4950
size_t index;
5051
if (!HasOption(name, &index))
5152
return false;
5253
*value = options_[index].value;
5354
return true;
5455
}
5556

56-
std::vector<fml::StringView> CommandLine::GetOptionValues(
57-
StringView name) const {
58-
std::vector<fml::StringView> ret;
57+
std::vector<std::string_view> CommandLine::GetOptionValues(
58+
std::string_view name) const {
59+
std::vector<std::string_view> ret;
5960
for (const auto& option : options_) {
6061
if (option.name == name)
6162
ret.push_back(option.value);
@@ -64,11 +65,11 @@ std::vector<fml::StringView> CommandLine::GetOptionValues(
6465
}
6566

6667
std::string CommandLine::GetOptionValueWithDefault(
67-
StringView name,
68-
StringView default_value) const {
68+
std::string_view name,
69+
std::string_view default_value) const {
6970
size_t index;
7071
if (!HasOption(name, &index))
71-
return default_value.ToString();
72+
return {default_value.data(), default_value.size()};
7273
return options_[index].value;
7374
}
7475

fml/command_line.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040

4141
#include <initializer_list>
4242
#include <string>
43+
#include <string_view>
4344
#include <unordered_map>
4445
#include <vector>
4546

4647
#include "flutter/fml/macros.h"
47-
#include "flutter/fml/string_view.h"
4848

4949
namespace fml {
5050

@@ -108,21 +108,21 @@ class CommandLine final {
108108
// Returns true if this command line has the option |name| (and if |index| is
109109
// non-null, sets |*index| to the index of the *last* occurrence of the given
110110
// option in |options()|) and false if not.
111-
bool HasOption(StringView name, size_t* index = nullptr) const;
111+
bool HasOption(std::string_view name, size_t* index = nullptr) const;
112112

113113
// Gets the value of the option |name|. Returns true (and sets |*value|) on
114114
// success and false (leaving |*value| alone) on failure.
115-
bool GetOptionValue(StringView name, std::string* value) const;
115+
bool GetOptionValue(std::string_view name, std::string* value) const;
116116

117117
// Gets all values of the option |name|. Returns all values, which may be
118118
// empty if the option is not specified.
119-
std::vector<StringView> GetOptionValues(StringView name) const;
119+
std::vector<std::string_view> GetOptionValues(std::string_view name) const;
120120

121121
// Gets the value of the option |name|, with a default if the option is not
122122
// specified. (Note: This doesn't return a const reference, since this would
123123
// make the |default_value| argument inconvenient/dangerous.)
124-
std::string GetOptionValueWithDefault(StringView name,
125-
StringView default_value) const;
124+
std::string GetOptionValueWithDefault(std::string_view name,
125+
std::string_view default_value) const;
126126

127127
private:
128128
bool has_argv0_ = false;

fml/command_line_unittest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "flutter/fml/command_line.h"
66

7+
#include <string_view>
78
#include <utility>
89

910
#include "flutter/fml/macros.h"
@@ -315,7 +316,7 @@ TEST(CommandLineTest, MultipleOccurrencesOfOption) {
315316
CommandLine::Option("flag1", "value3")};
316317
EXPECT_EQ("value3", cl.GetOptionValueWithDefault("flag1", "nope"));
317318
EXPECT_EQ("value2", cl.GetOptionValueWithDefault("flag2", "nope"));
318-
std::vector<StringView> values = cl.GetOptionValues("flag1");
319+
std::vector<std::string_view> values = cl.GetOptionValues("flag1");
319320
ASSERT_EQ(2u, values.size());
320321
EXPECT_EQ("value1", values[0]);
321322
EXPECT_EQ("value3", values[1]);

fml/string_view.cc

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)