Skip to content

Commit 14723aa

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 d70fa0d commit 14723aa

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
@@ -1215,6 +1215,8 @@ cc_library(
12151215
name = "null_file_system",
12161216
hdrs = ["null_file_system.h"],
12171217
deps = [
1218+
"@com_google_absl//absl/status",
1219+
"@com_google_absl//absl/strings:string_view",
12181220
"@xla//xla/tsl/platform:env",
12191221
],
12201222
)
@@ -1441,6 +1443,7 @@ cc_library(
14411443
deps = [
14421444
":random",
14431445
":retrying_utils",
1446+
"@com_google_absl//absl/strings:string_view",
14441447
"@xla//xla/tsl/platform:env",
14451448
"@xla//xla/tsl/platform:errors",
14461449
"@xla//xla/tsl/platform:status",
@@ -1456,7 +1459,6 @@ tsl_cc_test(
14561459
":str_util",
14571460
"@com_google_googletest//:gtest_main",
14581461
"@xla//xla/tsl/lib/core:status_test_util",
1459-
"@xla//xla/tsl/platform:env_impl",
14601462
"@xla//xla/tsl/platform:test",
14611463
],
14621464
)

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)