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

Broken ocl::Path(const Path &) constructor #159

Open
petterreinholdtsen opened this issue Sep 11, 2023 · 4 comments
Open

Broken ocl::Path(const Path &) constructor #159

petterreinholdtsen opened this issue Sep 11, 2023 · 4 comments

Comments

@petterreinholdtsen
Copy link

The copy constructor for ocl::Path is a no-op, not copying anything from the source object. Why is it there? As far as I can tell, the code build just fine without the copy constructor. If it is needed and wanted, what about making it a proper copy constructor which make a copy of the content of the source object.

Here is a draft patch removing the copy constructor, and including a simple implementation of the list copying.


--- opencamlib-salsa.orig/src/geo/path.cpp	2023-09-11 12:07:29.133078761 +0200
+++ opencamlib-salsa/src/geo/path.cpp	2023-09-11 12:07:29.125078733 +0200
@@ -28,9 +28,12 @@
 Path::Path() {
 }
 
+  /*
 Path::Path(const Path &p) {
+  std::copy(p.span_list.begin(), p.span_list.end(),
+	    std::back_inserter(span_list));
 }
-
+  */
 Path::~Path() {
 }
 
--- opencamlib-salsa.orig/src/geo/path.hpp	2023-09-11 12:07:29.133078761 +0200
+++ opencamlib-salsa/src/geo/path.hpp	2023-09-11 12:07:29.125078733 +0200
@@ -98,7 +98,7 @@
         /// create empty path
         Path();
         /// copy constructor
-        Path(const Path &p);
+        //Path(const Path &p);
         /// destructor
         virtual ~Path();
 
@vespakoen
Copy link
Collaborator

It seems to be introduced (13 years ago) over here: 5cbe842

And wasn't used, even in the first commit.
Probably a leftover that got committed by accident.

I think we should probably remove it and enable a compiler flag to show unused variables.

@vespakoen
Copy link
Collaborator

vespakoen commented Sep 11, 2023

It does actually seems to be exported to the Python bindings, and other classes seem to have it as well, so perhaps there is / was a reason for it, I am guessing it might have to do with Pybind Boost.Python:

5cbe842#diff-0616b7317a8086d1a85467f49ed29c5fdbfde09ee5f98ead04bd224d992f8db8R143

@vespakoen
Copy link
Collaborator

Never mind, I wasn't aware of C++'s copy constructors, learned something new... so I guess the code makes it more clear / explicit that an shallow copy is "enough"?

What is different in your example compared to the shallow copy?

@petterreinholdtsen
Copy link
Author

petterreinholdtsen commented Sep 11, 2023 via email

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