Skip to content

Commit ad37c46

Browse files
zacmustincopybara-github
authored andcommitted
Update TSL FileExists to use absl::string_view.
Users passing `std::string` will not need updating, since `string_view` will perform an implicit conversion. PiperOrigin-RevId: 864529553
1 parent d22abb7 commit ad37c46

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

tsl/platform/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,8 @@ cc_library(
12181218
name = "null_file_system",
12191219
hdrs = ["null_file_system.h"],
12201220
deps = [
1221+
"@com_google_absl//absl/status",
1222+
"@com_google_absl//absl/strings:string_view",
12211223
"@xla//xla/tsl/platform:env",
12221224
],
12231225
)
@@ -1445,6 +1447,7 @@ cc_library(
14451447
deps = [
14461448
":random",
14471449
":retrying_utils",
1450+
"@com_google_absl//absl/strings:string_view",
14481451
"@xla//xla/tsl/platform:env",
14491452
"@xla//xla/tsl/platform:errors",
14501453
"@xla//xla/tsl/platform:status",
@@ -1460,7 +1463,6 @@ tsl_cc_test(
14601463
":str_util",
14611464
"@com_google_googletest//:gtest_main",
14621465
"@xla//xla/tsl/lib/core:status_test_util",
1463-
"@xla//xla/tsl/platform:env_impl",
14641466
"@xla//xla/tsl/platform:test",
14651467
],
14661468
)

tsl/platform/null_file_system.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ limitations under the License.
2020
#include <string>
2121
#include <vector>
2222

23+
#include "absl/status/status.h"
24+
#include "absl/strings/string_view.h"
2325
#include "xla/tsl/platform/env.h"
2426
#include "xla/tsl/platform/file_system.h"
2527
#include "xla/tsl/platform/file_system_helper.h"
@@ -62,7 +64,7 @@ class NullFileSystem : public FileSystem {
6264
"NewReadOnlyMemoryRegionFromFile unimplemented");
6365
}
6466

65-
absl::Status FileExists(const string& fname,
67+
absl::Status FileExists(absl::string_view fname,
6668
TransactionToken* token) override {
6769
return errors::Unimplemented("FileExists unimplemented");
6870
}

tsl/platform/retrying_file_system.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ limitations under the License.
1818

1919
#include <functional>
2020
#include <memory>
21-
#include <string>
2221
#include <vector>
2322

23+
#include "absl/strings/string_view.h"
2424
#include "xla/tsl/platform/env.h"
2525
#include "xla/tsl/platform/errors.h"
2626
#include "xla/tsl/platform/file_system.h"
@@ -56,7 +56,7 @@ class RetryingFileSystem : public FileSystem {
5656
const string& filename, TransactionToken* token,
5757
std::unique_ptr<ReadOnlyMemoryRegion>* result) override;
5858

59-
absl::Status FileExists(const string& fname,
59+
absl::Status FileExists(absl::string_view fname,
6060
TransactionToken* token) override {
6161
return RetryingUtils::CallWithRetries(
6262
[this, &fname, token]() {

tsl/platform/retrying_file_system_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class MockFileSystem : public FileSystem {
127127
return calls_.ConsumeNextCall("NewReadOnlyMemoryRegionFromFile");
128128
}
129129

130-
absl::Status FileExists(const string& fname,
130+
absl::Status FileExists(absl::string_view fname,
131131
TransactionToken* token) override {
132132
return calls_.ConsumeNextCall("FileExists");
133133
}

0 commit comments

Comments
 (0)