-
Notifications
You must be signed in to change notification settings - Fork 266
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
Speed up quoted printable encoding #228
Conversation
Encoding to quoted printable was quite slow in cases when calling string:substr and subsequent lists:concat for inserting soft newline was used too often. New implementation uses only fast head operations.
For comparing before/after performance I used following:
Both calls takes seconds before improvement and hundreds/tens of milliseconds after. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
insert_soft_newline([H | T], AfterPos) when AfterPos > 0 -> | ||
[H | insert_soft_newline(T, AfterPos - 1)]; | ||
insert_soft_newline(Str, 0) -> | ||
[$\n, $\r, $= | Str]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: I think you can do "\n\r=" ++ Str
and compiler will be able to optimize it to what your code looks like now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Should I change it before merge or keep it as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine as it is now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks!
Good work, thank you! |
@seriyps Ready to be merged? |
@mworrell yes |
@bossek Merging now, thank you for your contribution! |
@mworrell Glad to help :-) |
Encoding to quoted printable was quite slow in cases when calling
string:substr and subsequent lists:concat for inserting soft newline was
used too often. New implementation uses only fast head operations.