aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/util
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-28 13:35:10 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-28 13:41:11 -0700
commiteece29de7b888ccee3f758d2de0967ad674c87a3 (patch)
treefd74e39d4e6e47f1cc38cbff7307f8f312e9be50 /tensorflow/core/util
parent88ab8b0bd6ca4dba10a5ed8852e23eacfb0f888e (diff)
Removed redundant std::string -> string conversions.
PiperOrigin-RevId: 210596417
Diffstat (limited to 'tensorflow/core/util')
-rw-r--r--tensorflow/core/util/tensor_bundle/tensor_bundle.cc16
-rw-r--r--tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc2
2 files changed, 9 insertions, 9 deletions
diff --git a/tensorflow/core/util/tensor_bundle/tensor_bundle.cc b/tensorflow/core/util/tensor_bundle/tensor_bundle.cc
index 7190614706..ea8a259d1a 100644
--- a/tensorflow/core/util/tensor_bundle/tensor_bundle.cc
+++ b/tensorflow/core/util/tensor_bundle/tensor_bundle.cc
@@ -370,14 +370,14 @@ Status PadAlignment(FileOutputBuffer* out, int alignment, int64* size) {
BundleWriter::BundleWriter(Env* env, StringPiece prefix, const Options& options)
: env_(env),
options_(options),
- prefix_(std::string(prefix)),
+ prefix_(prefix),
tmp_metadata_path_(strings::StrCat(MetaFilename(prefix_), ".tempstate",
random::New64())),
tmp_data_path_(strings::StrCat(DataFilename(prefix_, 0, 1), ".tempstate",
random::New64())),
out_(nullptr),
size_(0) {
- status_ = env_->CreateDir(std::string(io::Dirname(prefix_)));
+ status_ = env_->CreateDir(string(io::Dirname(prefix_)));
if (!status_.ok() && !errors::IsAlreadyExists(status_)) {
return;
}
@@ -394,7 +394,7 @@ BundleWriter::BundleWriter(Env* env, StringPiece prefix, const Options& options)
Status BundleWriter::Add(StringPiece key, const Tensor& val) {
if (!status_.ok()) return status_;
CHECK_NE(key, kHeaderEntryKey);
- const string key_string = std::string(key);
+ const string key_string(key);
if (entries_.find(key_string) != entries_.end()) {
status_ = errors::InvalidArgument("Adding duplicate key: ", key);
return status_;
@@ -445,7 +445,7 @@ Status BundleWriter::AddSlice(StringPiece full_tensor_key,
// In the case of a sharded save, MergeBundles() is responsible for merging
// the "slices" field of multiple metadata entries corresponding to the same
// full tensor.
- const string full_tensor_key_string = std::string(full_tensor_key);
+ const string full_tensor_key_string(full_tensor_key);
BundleEntryProto* full_entry = &entries_[full_tensor_key_string];
if (full_entry->dtype() != DT_INVALID) {
CHECK_EQ(full_entry->dtype(), slice_tensor.dtype());
@@ -600,7 +600,7 @@ static Status MergeOneBundle(Env* env, StringPiece prefix,
// Loops through the non-header to-merge entries.
BundleEntryProto to_merge_entry;
for (; iter->Valid(); iter->Next()) {
- const string key = std::string(iter->key());
+ const string key(iter->key());
const auto entry_iter = merge_state->entries.find(key);
// Illegal: the duplicated entry is a non-slice tensor.
@@ -649,7 +649,7 @@ Status MergeBundles(Env* env, gtl::ArraySlice<string> prefixes,
// Merges all metadata tables.
// TODO(zhifengc): KeyValue sorter if it becomes too big.
MergeState merge;
- Status status = env->CreateDir(std::string(io::Dirname(merged_prefix)));
+ Status status = env->CreateDir(string(io::Dirname(merged_prefix)));
if (!status.ok() && !errors::IsAlreadyExists(status)) return status;
for (int i = 0; i < prefixes.size(); ++i) {
TF_RETURN_IF_ERROR(MergeOneBundle(env, prefixes[i], &merge));
@@ -697,7 +697,7 @@ Status MergeBundles(Env* env, gtl::ArraySlice<string> prefixes,
BundleReader::BundleReader(Env* env, StringPiece prefix)
: env_(env),
- prefix_(std::string(prefix)),
+ prefix_(prefix),
metadata_(nullptr),
table_(nullptr),
iter_(nullptr) {
@@ -919,7 +919,7 @@ Status BundleReader::GetSliceValue(StringPiece full_tensor_key,
const TensorShape full_shape(TensorShape(full_tensor_entry.shape()));
std::vector<std::pair<TensorSlice, string>> details;
- const string full_tensor_key_string = std::string(full_tensor_key);
+ const string full_tensor_key_string(full_tensor_key);
const TensorSliceSet* tss =
gtl::FindPtrOrNull(tensor_slices_, full_tensor_key_string);
diff --git a/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc b/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc
index 92ce8ae00e..59c42baa06 100644
--- a/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc
+++ b/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc
@@ -107,7 +107,7 @@ std::vector<string> AllTensorKeys(BundleReader* reader) {
reader->Seek(kHeaderEntryKey);
reader->Next();
for (; reader->Valid(); reader->Next()) {
- ret.push_back(std::string(reader->key()));
+ ret.emplace_back(reader->key());
}
return ret;
}