Replacing ::Cord with absl::Cord.
PiperOrigin-RevId: 309958768 Change-Id: I91aa6ffea8bd35384bdcc2f29f934c8cb33ca44e
This commit is contained in:
parent
cbec9ecd13
commit
f9a3aaf60d
@ -79,10 +79,10 @@ inline void SetProtobufStringSwapAllowed(std::string* src, std::string* dest) {
|
|||||||
// tools/proto_text's generated code. They have the same name as the versions
|
// tools/proto_text's generated code. They have the same name as the versions
|
||||||
// in core/platform/protobuf.h, so the generation code doesn't need to determine
|
// in core/platform/protobuf.h, so the generation code doesn't need to determine
|
||||||
// if the type is Cord or string at generation time.
|
// if the type is Cord or string at generation time.
|
||||||
inline std::string ProtobufStringToString(const Cord& s) {
|
inline std::string ProtobufStringToString(const absl::Cord& s) {
|
||||||
return s.ToString();
|
return s.ToString();
|
||||||
}
|
}
|
||||||
inline void SetProtobufStringSwapAllowed(std::string* src, Cord* dest) {
|
inline void SetProtobufStringSwapAllowed(std::string* src, absl::Cord* dest) {
|
||||||
dest->CopyFrom(*src);
|
dest->CopyFrom(*src);
|
||||||
}
|
}
|
||||||
#endif // defined(TENSORFLOW_PROTOBUF_USES_CORD)
|
#endif // defined(TENSORFLOW_PROTOBUF_USES_CORD)
|
||||||
|
@ -132,7 +132,7 @@ std::unique_ptr<StringListDecoder> NewStringListDecoder(const string& in) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TENSORFLOW_PROTOBUF_USES_CORD)
|
#if defined(TENSORFLOW_PROTOBUF_USES_CORD)
|
||||||
void AssignRefCounted(StringPiece src, core::RefCounted* obj, Cord* out) {
|
void AssignRefCounted(StringPiece src, core::RefCounted* obj, absl::Cord* out) {
|
||||||
obj->Ref();
|
obj->Ref();
|
||||||
out->Clear();
|
out->Clear();
|
||||||
// Defines a lambda to unref "obj" when Cord deletes this piece of
|
// Defines a lambda to unref "obj" when Cord deletes this piece of
|
||||||
@ -144,7 +144,7 @@ void AssignRefCounted(StringPiece src, core::RefCounted* obj, Cord* out) {
|
|||||||
cleanup);
|
cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeStringList(const tstring* strings, int64 n, Cord* out) {
|
void EncodeStringList(const tstring* strings, int64 n, absl::Cord* out) {
|
||||||
out->Clear();
|
out->Clear();
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
::strings::CordAppendVarint(strings[i].size(), out);
|
::strings::CordAppendVarint(strings[i].size(), out);
|
||||||
@ -154,7 +154,7 @@ void EncodeStringList(const tstring* strings, int64 n, Cord* out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecodeStringList(const Cord& src, string* strings, int64 n) {
|
bool DecodeStringList(const absl::Cord& src, string* strings, int64 n) {
|
||||||
std::vector<uint32> sizes(n);
|
std::vector<uint32> sizes(n);
|
||||||
CordReader reader(src);
|
CordReader reader(src);
|
||||||
int64 tot = 0;
|
int64 tot = 0;
|
||||||
@ -177,7 +177,7 @@ bool DecodeStringList(const Cord& src, string* strings, int64 n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecodeStringList(const Cord& src, tstring* strings, int64 n) {
|
bool DecodeStringList(const absl::Cord& src, tstring* strings, int64 n) {
|
||||||
std::vector<uint32> sizes(n);
|
std::vector<uint32> sizes(n);
|
||||||
CordReader reader(src);
|
CordReader reader(src);
|
||||||
int64 tot = 0;
|
int64 tot = 0;
|
||||||
@ -200,13 +200,13 @@ bool DecodeStringList(const Cord& src, tstring* strings, int64 n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyFromArray(Cord* c, const char* base, size_t bytes) {
|
void CopyFromArray(absl::Cord* c, const char* base, size_t bytes) {
|
||||||
c->CopyFrom(base, bytes);
|
c->CopyFrom(base, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CordStringListEncoderImpl : public StringListEncoder {
|
class CordStringListEncoderImpl : public StringListEncoder {
|
||||||
public:
|
public:
|
||||||
explicit CordStringListEncoderImpl(Cord* out) : out_(out) {}
|
explicit CordStringListEncoderImpl(absl::Cord* out) : out_(out) {}
|
||||||
~CordStringListEncoderImpl() override = default;
|
~CordStringListEncoderImpl() override = default;
|
||||||
|
|
||||||
void Append(const protobuf::MessageLite& m) override {
|
void Append(const protobuf::MessageLite& m) override {
|
||||||
@ -222,13 +222,13 @@ class CordStringListEncoderImpl : public StringListEncoder {
|
|||||||
void Finalize() override { out_->Append(rest_); }
|
void Finalize() override { out_->Append(rest_); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Cord* out_;
|
absl::Cord* out_;
|
||||||
string rest_;
|
string rest_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CordStringListDecoderImpl : public StringListDecoder {
|
class CordStringListDecoderImpl : public StringListDecoder {
|
||||||
public:
|
public:
|
||||||
explicit CordStringListDecoderImpl(const Cord& in) : reader_(in) {}
|
explicit CordStringListDecoderImpl(const absl::Cord& in) : reader_(in) {}
|
||||||
~CordStringListDecoderImpl() override = default;
|
~CordStringListDecoderImpl() override = default;
|
||||||
|
|
||||||
bool ReadSizes(std::vector<uint32>* sizes) override {
|
bool ReadSizes(std::vector<uint32>* sizes) override {
|
||||||
@ -254,11 +254,11 @@ class CordStringListDecoderImpl : public StringListDecoder {
|
|||||||
std::vector<char> tmp_;
|
std::vector<char> tmp_;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<StringListEncoder> NewStringListEncoder(Cord* out) {
|
std::unique_ptr<StringListEncoder> NewStringListEncoder(absl::Cord* out) {
|
||||||
return std::unique_ptr<StringListEncoder>(new CordStringListEncoderImpl(out));
|
return std::unique_ptr<StringListEncoder>(new CordStringListEncoderImpl(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<StringListDecoder> NewStringListDecoder(const Cord& in) {
|
std::unique_ptr<StringListDecoder> NewStringListDecoder(const absl::Cord& in) {
|
||||||
return std::unique_ptr<StringListDecoder>(new CordStringListDecoderImpl(in));
|
return std::unique_ptr<StringListDecoder>(new CordStringListDecoderImpl(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,31 +100,33 @@ std::unique_ptr<StringListDecoder> NewStringListDecoder(const string& in);
|
|||||||
// Store src contents in *out. If backing memory for src is shared with *out,
|
// Store src contents in *out. If backing memory for src is shared with *out,
|
||||||
// will ref obj during the call and will arrange to unref obj when no
|
// will ref obj during the call and will arrange to unref obj when no
|
||||||
// longer needed.
|
// longer needed.
|
||||||
void AssignRefCounted(StringPiece src, core::RefCounted* obj, Cord* out);
|
void AssignRefCounted(StringPiece src, core::RefCounted* obj, absl::Cord* out);
|
||||||
|
|
||||||
// TODO(kmensah): Macro guard this with a check for Cord support.
|
// TODO(kmensah): Macro guard this with a check for Cord support.
|
||||||
inline void CopyToArray(const Cord& src, char* dst) { src.CopyToArray(dst); }
|
inline void CopyToArray(const absl::Cord& src, char* dst) {
|
||||||
|
src.CopyToArray(dst);
|
||||||
|
}
|
||||||
|
|
||||||
// Copy n bytes of src to dst. If pos >= src.size() the result is empty.
|
// Copy n bytes of src to dst. If pos >= src.size() the result is empty.
|
||||||
// If pos + n > src.size() the subrange [pos, size()) is copied.
|
// If pos + n > src.size() the subrange [pos, size()) is copied.
|
||||||
inline void CopySubrangeToArray(const Cord& src, int64 pos, int64 n,
|
inline void CopySubrangeToArray(const absl::Cord& src, int64 pos, int64 n,
|
||||||
char* dst) {
|
char* dst) {
|
||||||
src.Subcord(pos, n).CopyToArray(dst);
|
src.Subcord(pos, n).CopyToArray(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store encoding of strings[0..n-1] in *out.
|
// Store encoding of strings[0..n-1] in *out.
|
||||||
void EncodeStringList(const tstring* strings, int64 n, Cord* out);
|
void EncodeStringList(const tstring* strings, int64 n, absl::Cord* out);
|
||||||
|
|
||||||
// Decode n strings from src and store in strings[0..n-1].
|
// Decode n strings from src and store in strings[0..n-1].
|
||||||
// Returns true if successful, false on parse error.
|
// Returns true if successful, false on parse error.
|
||||||
bool DecodeStringList(const Cord& src, std::string* strings, int64 n);
|
bool DecodeStringList(const absl::Cord& src, std::string* strings, int64 n);
|
||||||
bool DecodeStringList(const Cord& src, tstring* strings, int64 n);
|
bool DecodeStringList(const absl::Cord& src, tstring* strings, int64 n);
|
||||||
|
|
||||||
// Assigns base[0..bytes-1] to *c
|
// Assigns base[0..bytes-1] to *c
|
||||||
void CopyFromArray(Cord* c, const char* base, size_t bytes);
|
void CopyFromArray(absl::Cord* c, const char* base, size_t bytes);
|
||||||
|
|
||||||
std::unique_ptr<StringListEncoder> NewStringListEncoder(Cord* out);
|
std::unique_ptr<StringListEncoder> NewStringListEncoder(absl::Cord* out);
|
||||||
std::unique_ptr<StringListDecoder> NewStringListDecoder(const Cord& in);
|
std::unique_ptr<StringListDecoder> NewStringListDecoder(const absl::Cord& in);
|
||||||
#endif // defined(TENSORFLOW_PROTOBUF_USES_CORD)
|
#endif // defined(TENSORFLOW_PROTOBUF_USES_CORD)
|
||||||
|
|
||||||
} // namespace port
|
} // namespace port
|
||||||
|
@ -33,7 +33,7 @@ void CopyToBuffer(const string& src, char* dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLATFORM_GOOGLE
|
#ifdef PLATFORM_GOOGLE
|
||||||
void CopyToBuffer(const Cord& src, char* dest) { src.CopyToArray(dest); }
|
void CopyToBuffer(const absl::Cord& src, char* dest) { src.CopyToArray(dest); }
|
||||||
#endif
|
#endif
|
||||||
} // namespace port
|
} // namespace port
|
||||||
} // namespace toco
|
} // namespace toco
|
||||||
|
@ -80,7 +80,7 @@ tensorflow::Status Exists(const string& filename, const Options& options);
|
|||||||
|
|
||||||
// Copy `src` string to `dest`. User must ensure `dest` has enough space.
|
// Copy `src` string to `dest`. User must ensure `dest` has enough space.
|
||||||
#if defined(PLATFORM_GOOGLE)
|
#if defined(PLATFORM_GOOGLE)
|
||||||
void CopyToBuffer(const ::Cord& src, char* dest);
|
void CopyToBuffer(const ::absl::Cord& src, char* dest);
|
||||||
#endif // PLATFORM_GOOGLE
|
#endif // PLATFORM_GOOGLE
|
||||||
void CopyToBuffer(const string& src, char* dest);
|
void CopyToBuffer(const string& src, char* dest);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user