Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@BerndAmend
Copy link
Contributor

ChaiScript 6 always used a shared_ptr to wrap C++ objects created in
ChaiScript. Newer versions avoid this by only wrapping objects that cannot
be copied. This has the side effect that ChaiScript depends on correctly
implemented C++ copy and move constructors in unexpected locations.
I don't think the reduced overhead (by avoiding the shared_ptr) justifies
the new behavior in every case.
Therefore, I suggest we temporarily only perform this optimization if the class
is trivially destructible, until unexpected copies and moves in ChaiScript
are fixed (if this is even possible), or there is a sanitizer/compiler warning
that can detect these cases.
Before the change the following code will call the ctor once, move once,
and the dtor twice:
auto obj = MoveableObject();
After this change it will only call the ctor once and the dtor once.

ChaiScript 6 always used a shared_ptr to wrap C++ objects created in
ChaiScript. Newer versions avoid this by only wrapping objects that cannot
be copied. This has the side effect that ChaiScript depends on correctly
implemented C++ copy and move constructors in unexpected locations.
I don't think the reduced overhead (by avoiding the shared_ptr) justifies
the new behavior in every case.
Therefore, I suggest we temporarily only perform this optimization if the class
is trivially destructible, until unexpected copies and moves in ChaiScript
are fixed (if this is even possible), or there is a sanitizer/compiler warning
that can detect these cases.
Before the change the following code will call the ctor once, move once,
and the dtor twice:
  auto obj = MoveableObject();
After this change it will only call the ctor once and the dtor once.
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

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.