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

Optimize conversion from c to wrap #76

Open
PetrPPetrov opened this issue Mar 15, 2018 · 0 comments
Open

Optimize conversion from c to wrap #76

PetrPPetrov opened this issue Mar 15, 2018 · 0 comments
Assignees

Comments

@PetrPPetrov
Copy link
Owner

Right now, if use ternary operation ? : the C function is called twice:

inline std::string STL::BasicString::CStr() const
{
exception_info_t cur_exception_info;
std::string result(std::string(stl_basic_string_char_cstr_const(&cur_exception_info, GetRawPointer()) ? stl_basic_string_char_cstr_const(&cur_exception_info, GetRawPointer()) : ""));
STL::check_and_throw_exception(cur_exception_info.code, cur_exception_info.object_pointer);
return result;
}

however, better to generate something like that:

inline std::string STL::BasicString::CStr() const
{
exception_info_t cur_exception_info;
const char* c_result = stl_basic_string_char_cstr_const(&cur_exception_info, GetRawPointer());
std::string result(std::string(c_result ? c_result : ""));
STL::check_and_throw_exception(cur_exception_info.code, cur_exception_info.object_pointer);
return result;
}

@PetrPPetrov PetrPPetrov added this to the v0.4.2 milestone Mar 15, 2018
@PetrPPetrov PetrPPetrov self-assigned this Mar 15, 2018
@PetrPPetrov PetrPPetrov removed this from the v0.4.2 milestone Mar 29, 2018
PetrPPetrov added a commit that referenced this issue Jun 19, 2020
@PetrPPetrov PetrPPetrov reopened this Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant