Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-5817: [C++] Avoid copy of TUuid #3038

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/cpp/src/thrift/generate/t_cpp_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,12 @@ class t_cpp_generator : public t_oop_generator {
bool is_complex_type(t_type* ttype) {
ttype = get_true_type(ttype);

return ttype->is_container() || ttype->is_struct() || ttype->is_xception()
return ttype->is_container() //
|| ttype->is_struct() //
|| ttype->is_xception()
|| (ttype->is_base_type()
&& (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING));
&& ((((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING)
|| (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_UUID)));
}

void set_use_include_prefix(bool use_include_prefix) { use_include_prefix_ = use_include_prefix; }
Expand Down Expand Up @@ -4485,7 +4488,7 @@ string t_cpp_generator::type_name(t_type* ttype, bool in_typedef, bool arg) {
return bname;
}

if (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING) {
if ((((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING) || ((((t_base_type*)ttype)->get_base() == t_base_type::TYPE_UUID))) {
return "const " + bname + "&";
} else {
return "const " + bname;
Expand Down
4 changes: 2 additions & 2 deletions lib/c_glib/test/testthrifttestclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class TestHandler : public ThriftTestIf {
out = thing;
}

apache::thrift::TUuid testUuid(const apache::thrift::TUuid thing) override {
void testUuid(apache::thrift::TUuid& out, const apache::thrift::TUuid& thing) override {
cout << "[C -> C++] testUuid(\"" << thing << "\")" << '\n';
return thing;
out = thing;
}

void testStruct(Xtruct& out, const Xtruct &thing) override {
Expand Down
8 changes: 4 additions & 4 deletions lib/c_glib/test/testthrifttestzlibclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ class TestHandler : public ThriftTestIf {
out = thing;
}

apache::thrift::TUuid testUuid(const apache::thrift::TUuid thing) override {
void testUuid(apache::thrift::TUuid& out, const apache::thrift::TUuid& thing) override {
cout << "[C -> C++] testUuid(\"" << thing << "\")" << '\n';
return thing;
out = thing;
}

void testStruct(Xtruct& out, const Xtruct &thing) override {
Expand Down Expand Up @@ -297,7 +297,7 @@ class TestHandler : public ThriftTestIf {
}

void testException(const std::string &arg)
throw(Xception, apache::thrift::TException) override
noexcept(false) override
{
cout << "[C -> C++] testException(" << arg << ")" << '\n';
if (arg.compare("Xception") == 0) {
Expand All @@ -315,7 +315,7 @@ class TestHandler : public ThriftTestIf {
}
}

void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) override {
void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) noexcept(false) override {

cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << '\n';

Expand Down
4 changes: 3 additions & 1 deletion test/cpp/src/TestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ bool print_eq(T expected, T actual) {
#define UUID_TEST(func, value, expected) \
cout << #func "(" << value << ") = "; \
try { \
if (!print_eq(expected, testClient.func(value))) \
TUuid ret; \
testClient.func(ret, value); \
if (!print_eq(expected, ret)) \
return_code |= ERR_BASETYPES; \
} catch (TTransportException&) { \
throw; \
Expand Down
9 changes: 5 additions & 4 deletions test/cpp/src/TestServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class TestHandler : public ThriftTestIf {
_return = thing;
}

TUuid testUuid(const TUuid thing) override {
void testUuid(apache::thrift::TUuid& _return, const apache::thrift::TUuid& thing) override {
printf("testUuid(\"{%s}\")\n", to_string(thing).c_str());
return thing;
_return = thing;
}

void testStruct(Xtruct& out, const Xtruct& thing) override {
Expand Down Expand Up @@ -447,8 +447,9 @@ class TestHandlerAsync : public ThriftTestCobSvIf {
cob(res);
}

void testUuid(::std::function<void(TUuid const& _return)> cob, const TUuid thing) override {
TUuid res = _delegate->testUuid(thing);
void testUuid(::std::function<void(apache::thrift::TUuid const& _return)> cob, const apache::thrift::TUuid& thing) override {
TUuid res;
_delegate->testUuid(res, thing);
cob(res);
}

Expand Down
Loading