aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-11-10 13:12:49 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-11-10 16:46:26 -0800
commit83c2da808e96dc5c9c3e80353d1db58a17502bf1 (patch)
tree185b741e08b55fbe8dfa07013a2fc5ef3c7797de
parentf157cc92a895b0cd9f5f15cc459e60ab0c98c875 (diff)
Removed StringPiece::set and StringPiece::clear, as they have no absl::string_view equivalents.
This will allow for a more convenient transition to absl::string_view. Calls to set StringPiece::set and StringPiece::clear were replaced with the StringPiece constructor as follows: string_piece_foo.set(data, size) => string_piece_foo = StringPiece(data, size) string_piece_foo.clear() => string_piece_foo = StringPiece() PiperOrigin-RevId: 175326576
-rw-r--r--ISSUE_TEMPLATE.md1
-rw-r--r--tensorflow/contrib/android/asset_manager_filesystem.cc4
-rw-r--r--tensorflow/core/framework/op_gen_lib.cc4
-rw-r--r--tensorflow/core/framework/rendezvous.cc18
-rw-r--r--tensorflow/core/kernels/immutable_constant_op_test.cc4
-rw-r--r--tensorflow/core/lib/core/stringpiece.h11
-rw-r--r--tensorflow/core/lib/io/block.cc2
-rw-r--r--tensorflow/core/lib/strings/str_util.cc4
-rw-r--r--tensorflow/core/lib/strings/strcat.cc2
-rw-r--r--tensorflow/core/platform/cloud/gcs_file_system.cc2
-rw-r--r--tensorflow/core/util/memmapped_file_system.cc5
-rw-r--r--tensorflow/core/util/semver_test.cc2
-rw-r--r--tensorflow/python/lib/core/strings.i4
13 files changed, 27 insertions, 36 deletions
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index 1f6ae1aba5..1a401997c6 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -1,4 +1,5 @@
Please go to Stack Overflow for help and support:
+
https://stackoverflow.com/questions/tagged/tensorflow
If you open a GitHub issue, here is our policy:
diff --git a/tensorflow/contrib/android/asset_manager_filesystem.cc b/tensorflow/contrib/android/asset_manager_filesystem.cc
index 9e4d3290c3..380a652435 100644
--- a/tensorflow/contrib/android/asset_manager_filesystem.cc
+++ b/tensorflow/contrib/android/asset_manager_filesystem.cc
@@ -97,7 +97,7 @@ class RandomAccessFileFromAsset : public RandomAccessFile {
off64_t new_offset = AAsset_seek64(asset.get(), offset, SEEK_SET);
off64_t length = AAsset_getLength64(asset.get());
if (new_offset < 0) {
- result->set(scratch, 0);
+ *result = StringPiece(scratch, 0);
return errors::OutOfRange("Read after file end.");
}
const off64_t region_left =
@@ -106,7 +106,7 @@ class RandomAccessFileFromAsset : public RandomAccessFile {
if (read < 0) {
return errors::Internal("Error reading from asset.");
}
- result->set(scratch, region_left);
+ *result = StringPiece(scratch, region_left);
return (region_left == to_read)
? Status::OK()
: errors::OutOfRange("Read less bytes than requested.");
diff --git a/tensorflow/core/framework/op_gen_lib.cc b/tensorflow/core/framework/op_gen_lib.cc
index 1e93e9be09..d84d5431e9 100644
--- a/tensorflow/core/framework/op_gen_lib.cc
+++ b/tensorflow/core/framework/op_gen_lib.cc
@@ -84,7 +84,7 @@ static bool SplitAt(char split_ch, StringPiece* orig,
auto pos = orig->find(split_ch);
if (pos == StringPiece::npos) {
*before_split = *orig;
- orig->clear();
+ *orig = StringPiece();
return false;
} else {
*before_split = orig->substr(0, pos);
@@ -236,7 +236,7 @@ string PBTxtFromMultiline(StringPiece multiline_pbtxt) {
unescaped.push_back('\n');
}
strings::StrAppend(&unescaped, line);
- line.clear();
+ line = StringPiece();
}
// Escape what we extracted and then output it in quotes.
diff --git a/tensorflow/core/framework/rendezvous.cc b/tensorflow/core/framework/rendezvous.cc
index a9e4c1cfb1..90756a4f2f 100644
--- a/tensorflow/core/framework/rendezvous.cc
+++ b/tensorflow/core/framework/rendezvous.cc
@@ -36,15 +36,15 @@ namespace tensorflow {
Rendezvous::ParsedKey& Rendezvous::ParsedKey::operator=(const ParsedKey& b) {
const char* b_base = b.buf_.data();
buf_ = b.buf_;
- src_device.set(buf_.data() + (b.src_device.data() - b_base),
- b.src_device.size());
+ src_device = StringPiece(buf_.data() + (b.src_device.data() - b_base),
+ b.src_device.size());
src = b.src;
src_incarnation = b.src_incarnation;
- dst_device.set(buf_.data() + (b.dst_device.data() - b_base),
- b.dst_device.size());
+ dst_device = StringPiece(buf_.data() + (b.dst_device.data() - b_base),
+ b.dst_device.size());
dst = b.dst;
- edge_name.set(buf_.data() + (b.edge_name.data() - b_base),
- b.edge_name.size());
+ edge_name = StringPiece(buf_.data() + (b.edge_name.data() - b_base),
+ b.edge_name.size());
return *this;
}
@@ -104,9 +104,9 @@ Status Rendezvous::ParseKey(StringPiece key, ParsedKey* out) {
strings::HexStringToUint64(parts[1], &out->src_incarnation) &&
DeviceNameUtils::ParseFullName(parts[2], &out->dst) &&
!parts[3].empty()) {
- out->src_device.set(parts[0].data(), parts[0].size());
- out->dst_device.set(parts[2].data(), parts[2].size());
- out->edge_name.set(parts[3].data(), parts[3].size());
+ out->src_device = StringPiece(parts[0].data(), parts[0].size());
+ out->dst_device = StringPiece(parts[2].data(), parts[2].size());
+ out->edge_name = StringPiece(parts[3].data(), parts[3].size());
return Status::OK();
}
return errors::InvalidArgument("Invalid rendezvous key: ", key);
diff --git a/tensorflow/core/kernels/immutable_constant_op_test.cc b/tensorflow/core/kernels/immutable_constant_op_test.cc
index b318c9c79a..b3814331ee 100644
--- a/tensorflow/core/kernels/immutable_constant_op_test.cc
+++ b/tensorflow/core/kernels/immutable_constant_op_test.cc
@@ -147,8 +147,8 @@ Status CreateTempFile(Env* env, float value, uint64 size, string* filename) {
std::unique_ptr<WritableFile> file;
TF_RETURN_IF_ERROR(env->NewWritableFile(*filename, &file));
for (uint64 i = 0; i < size; ++i) {
- StringPiece sp;
- sp.set(&value, sizeof(value));
+ StringPiece sp(static_cast<char*>(static_cast<void*>(&value)),
+ sizeof(value));
TF_RETURN_IF_ERROR(file->Append(sp));
}
TF_RETURN_IF_ERROR(file->Close());
diff --git a/tensorflow/core/lib/core/stringpiece.h b/tensorflow/core/lib/core/stringpiece.h
index 7d258b36c5..94f4a377f1 100644
--- a/tensorflow/core/lib/core/stringpiece.h
+++ b/tensorflow/core/lib/core/stringpiece.h
@@ -51,11 +51,6 @@ class StringPiece {
// Create a slice that refers to s[0,strlen(s)-1]
StringPiece(const char* s) : data_(s), size_(strlen(s)) {}
- void set(const void* data, size_t len) {
- data_ = reinterpret_cast<const char*>(data);
- size_ = len;
- }
-
// Return a pointer to the beginning of the referenced data
const char* data() const { return data_; }
@@ -79,12 +74,6 @@ class StringPiece {
return data_[n];
}
- // Change this slice to refer to an empty array
- void clear() {
- data_ = "";
- size_ = 0;
- }
-
// Drop the first "n" bytes from this slice.
void remove_prefix(size_t n) {
assert(n <= size());
diff --git a/tensorflow/core/lib/io/block.cc b/tensorflow/core/lib/io/block.cc
index 1fa26d9147..4c30486cc4 100644
--- a/tensorflow/core/lib/io/block.cc
+++ b/tensorflow/core/lib/io/block.cc
@@ -199,7 +199,7 @@ class Block::Iter : public Iterator {
restart_index_ = num_restarts_;
status_ = errors::DataLoss("bad entry in block");
key_.clear();
- value_.clear();
+ value_ = StringPiece();
}
bool ParseNextKey() {
diff --git a/tensorflow/core/lib/strings/str_util.cc b/tensorflow/core/lib/strings/str_util.cc
index 8509c9a041..240e1454e5 100644
--- a/tensorflow/core/lib/strings/str_util.cc
+++ b/tensorflow/core/lib/strings/str_util.cc
@@ -407,11 +407,11 @@ bool ConsumeNonWhitespace(StringPiece* s, StringPiece* val) {
}
const size_t n = p - s->data();
if (n > 0) {
- val->set(s->data(), n);
+ *val = StringPiece(s->data(), n);
s->remove_prefix(n);
return true;
} else {
- val->clear();
+ *val = StringPiece();
return false;
}
}
diff --git a/tensorflow/core/lib/strings/strcat.cc b/tensorflow/core/lib/strings/strcat.cc
index 46a45a6678..5b1cff486d 100644
--- a/tensorflow/core/lib/strings/strcat.cc
+++ b/tensorflow/core/lib/strings/strcat.cc
@@ -45,7 +45,7 @@ AlphaNum::AlphaNum(Hex hex) {
value >>= 4;
mask >>= 4;
} while (mask != 0);
- piece_.set(writer, end - writer);
+ piece_ = StringPiece(writer, end - writer);
}
// ----------------------------------------------------------------------
diff --git a/tensorflow/core/platform/cloud/gcs_file_system.cc b/tensorflow/core/platform/cloud/gcs_file_system.cc
index e82aebad0b..17fe704b79 100644
--- a/tensorflow/core/platform/cloud/gcs_file_system.cc
+++ b/tensorflow/core/platform/cloud/gcs_file_system.cc
@@ -247,7 +247,7 @@ class GcsRandomAccessFile : public RandomAccessFile {
/// The implementation of reads with an LRU block cache. Thread safe.
Status Read(uint64 offset, size_t n, StringPiece* result,
char* scratch) const override {
- result->clear();
+ *result = StringPiece();
std::vector<char> out;
TF_RETURN_IF_ERROR(file_block_cache_->Read(filename_, offset, n, &out));
std::memcpy(scratch, out.data(), std::min(out.size(), n));
diff --git a/tensorflow/core/util/memmapped_file_system.cc b/tensorflow/core/util/memmapped_file_system.cc
index e077e94cf8..a0f43d2d4a 100644
--- a/tensorflow/core/util/memmapped_file_system.cc
+++ b/tensorflow/core/util/memmapped_file_system.cc
@@ -58,12 +58,13 @@ class RandomAccessFileFromMemmapped : public RandomAccessFile {
Status Read(uint64 offset, size_t to_read, StringPiece* result,
char* scratch) const override {
if (offset >= length_) {
- result->set(scratch, 0);
+ *result = StringPiece(scratch, 0);
return Status(error::OUT_OF_RANGE, "Read after file end");
}
const uint64 region_left =
std::min(length_ - offset, static_cast<uint64>(to_read));
- result->set(reinterpret_cast<const uint8*>(data_) + offset, region_left);
+ *result =
+ StringPiece(reinterpret_cast<const char*>(data_) + offset, region_left);
return (region_left == to_read)
? Status::OK()
: Status(error::OUT_OF_RANGE, "Read less bytes than requested");
diff --git a/tensorflow/core/util/semver_test.cc b/tensorflow/core/util/semver_test.cc
index 0647f670c7..fdc34fa58b 100644
--- a/tensorflow/core/util/semver_test.cc
+++ b/tensorflow/core/util/semver_test.cc
@@ -39,7 +39,7 @@ bool ConsumeDotSeparatedIdentifiers(StringPiece* s, const string& prefix,
for (i = 0; i < s->size() && IsDotOrIdentifierChar((*s)[i]); ++i) {
// Intentionally empty
}
- val->set(s->data(), i);
+ *val = StringPiece(s->data(), i);
s->remove_prefix(i);
return i > 0;
}
diff --git a/tensorflow/python/lib/core/strings.i b/tensorflow/python/lib/core/strings.i
index 938c13e30e..9d807e51be 100644
--- a/tensorflow/python/lib/core/strings.i
+++ b/tensorflow/python/lib/core/strings.i
@@ -40,7 +40,7 @@ limitations under the License.
// Returns true on success, false on failure.
bool _BytesToStringPiece(PyObject* obj, tensorflow::StringPiece* result) {
if (obj == Py_None) {
- result->clear();
+ *result = tensorflow::StringPiece();
} else {
char* ptr;
Py_ssize_t len;
@@ -48,7 +48,7 @@ bool _BytesToStringPiece(PyObject* obj, tensorflow::StringPiece* result) {
// Python has raised an error (likely TypeError or UnicodeEncodeError).
return false;
}
- result->set(ptr, len);
+ *result = tensorflow::StringPiece(ptr, len);
}
return true;
}