Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generate path strings in C++ for PDF and PS #4197

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

Merged
merged 7 commits into from
Mar 13, 2015

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Mar 6, 2015

This is an optimization I've meant to implement for a long time.

The hottest spot performance-wise in the PDF and PS backends is the conversion of Path objects to a string of commands to draw that path. This has been done in C++ in the SVG backend for a long time -- this generalizes that code to make it usable in the PDF and PS backends as well.

template <class PathIterator>
void convert_to_svg(PathIterator &path,
Copy link
Member

Choose a reason for hiding this comment

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

Do we consider this part of the public API?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. It's in a module with a leading underscore (_path).

@tacaswell tacaswell added this to the next point release milestone Mar 9, 2015
@tacaswell
Copy link
Member

I miss writing c++ regularly.

@mdboom
Copy link
Member Author

mdboom commented Mar 9, 2015

I've updated this with changes that I think address all of the comments above.

if (code == 0x4f) {
if ((p = __append_to_string(p, buffer, *buffersize, codes[4])) == NULL) return 1;
} else {
size = sizes[code - 1];
Copy link
Member

Choose a reason for hiding this comment

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

This should probably have a check that code < 5 so we can't walk out the end.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. This should be fixed now as well.

@mdboom
Copy link
Member Author

mdboom commented Mar 9, 2015

I miss writing c++ regularly.

sarcasm?


--wait;
if ((p = __append_to_string(p, buffer, *buffersize, "\n")) == NULL) return 1;
}

*p = '\0';
Copy link
Member

Choose a reason for hiding this comment

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

This should use __append_to_string too? I think this can be an issue if the path is exactly the length of the buffer when the '\n' is added.

@tacaswell
Copy link
Member

Sorry, one more nit-pick.

I really do miss c++ a bit.

@mdboom
Copy link
Member Author

mdboom commented Mar 10, 2015

BTW -- hold off one more second: I have one more improvement I want to make...

@tacaswell
Copy link
Member

@mdboom That last commits seems to have broken everything 😈

@mdboom
Copy link
Member Author

mdboom commented Mar 13, 2015

Interesting -- PyBytes_FromStringAndSize silently doesn't allocate a new object when size is 0. Fixed.

tacaswell added a commit that referenced this pull request Mar 13, 2015
PRF : Generate path strings in C++ for PDF and PS
@tacaswell tacaswell merged commit e783caa into matplotlib:master Mar 13, 2015
@mdboom mdboom deleted the faster-paths branch November 10, 2015 02:38
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.

2 participants