-
-
Notifications
You must be signed in to change notification settings - Fork 743
3x faster byLine implementation on OSX, probably faster on Linux as well #3089
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
Conversation
ptrdiff_t getdelim(char**, size_t*, int, FILE*); | ||
// getline() always comes together with getdelim() | ||
ptrdiff_t getline(char**, size_t*, FILE*); | ||
} |
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.
Wouldn't that be better to use a port of the actual C header of the plateform ?
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.
Yes, we should update core.stdc.stdio
and core.sys.posix.stdio
.
What's the bugzilla issue about this? |
Please note that readlnImpl is currently broken: #2794 |
Apparently getdelim is a Posix function and should be available on many platforms. |
if (n > 128 * 1024) | ||
{ | ||
// Bound memory used by readln | ||
free(lineptr); |
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 with leaking this until program exit, but valgrind would report this as leak.
Adding a ~static this() {}
might run into circular dependency issues though.
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.
Fortunately we have std.stdiobase
for that, where we can include a call to the module destructor as well.
Auto-merge toggled on |
3x faster byLine implementation on OSX, probably faster on Linux as well
@MartinNowak: yah, though |
No idea, MSVC 9 does not seem to be to old, and some of the more obscure platforms like HP-UX lack this function but aren't supported anyhow. OSX10.5 and FBSD6 are really old by now. |
Better keep it until we have updated the declarations in druntime. |
3x faster byLine implementation on OSX, probably faster on Linux as well Signed-off-by: Martin Krejcirik <mk@krej.cz>
3x faster byLine implementation on OSX, probably faster on Linux as well Signed-off-by: Martin Krejcirik <mk@krej.cz>
These changes make byLine more than 3x faster on OSX without changing semantics. Given that part of the changes involve paths taken by the other OSs, it's possible there's speedup elsewhere as well. Please measure, thanks!