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

DM-13750: Move BaseRecord.__str__ implementation to C++. #328

Merged
merged 1 commit into from Mar 15, 2018

Conversation

TallJimbo
Copy link
Member

Old implementation was very inefficient, even in Python, but we can make it even faster by moving it to C++.

Copy link
Contributor

@natelust natelust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, just curious about your opinion on my comment.



void BaseRecord::_stream(std::ostream & os) const {
PrintField functor(this, &os);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would find this much clearer and easier to read if you wrote this as a lambda with a capture on this and os. It would put the function right next to where it was used, and reduce many lines in this file. This seems exactly to be the kind of thing that lambdas were made for. It would also negate the need to get the address of os to pass into the functor, just to keep the size of the functor small, you could simply reference capture os, and have it as a reference all the way down.

Also, if a functor is used, please consider reverse the arguments of BaseRecord and std::ostream to put them in the same order as operator<<. I dont know if it is standard to pass this first, and if so fine, but it seems weirdly asymmetric.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

I was thinking in C++11, which does not permit "universal lambdas" (lambdas with templated function-call operators) instead of C++14, which does.

@TallJimbo TallJimbo force-pushed the tickets/DM-13750 branch 2 times, most recently from a302b06 to 8803a2d Compare March 15, 2018 14:32
Old implementation was very inefficient, even in Python, but
we can make it even faster by moving it to C++.
@TallJimbo TallJimbo merged commit fbf2208 into master Mar 15, 2018
@ktlim ktlim deleted the tickets/DM-13750 branch August 25, 2018 06:44
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.

None yet

2 participants