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

Improve exception safety with smart pointers #33

Closed
elfring opened this issue May 14, 2018 · 4 comments
Closed

Improve exception safety with smart pointers #33

elfring opened this issue May 14, 2018 · 4 comments

Comments

@elfring
Copy link

elfring commented May 14, 2018

Would you like to wrap any pointer variables with the template class “std::unique_ptr”?

@kishorenc
Copy link
Member

kishorenc commented May 14, 2018

@elfring I'm generally a fan of smart pointers as raw pointers can become hard to manage. In this case, however I refrained from wrapping for a couple of reasons:

  1. Parts of Typesense initially began as a C project, and still uses some C-style code so those parts just used raw pointers.
  2. To a lesser extent, I was worried about the performance overhead introduced (admittedly this is more of a case for shared_ptr than unique_ptr) in hot loops. I did do some initial benchmarks where I saw some serious degradation.

In the end, instead of adopting a mixed style, just ended up not using it anywhere. To detect and prevent leaks, we have an integration test suite (which is not part of this repo) that's run under Valgrind.

@elfring
Copy link
Author

elfring commented May 14, 2018

How do you think about to improve the implementation of the member function “array::remove_index” (for example)?

@kishorenc
Copy link
Member

@elfring I'm sorry for going silent on this thread. We're comfortable with using raw pointers as of today, given the heavy interoperability with the C libraries we're using. We might relook this at future. Thanks for bringing this up though!

@elfring
Copy link
Author

elfring commented Jun 9, 2018

The interoperability concerns do not matter for affected C++ classes.
Under which circumstances will you start to care for exception safety?

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

2 participants