-
-
Notifications
You must be signed in to change notification settings - Fork 706
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
Small performance increase for std.conv.text/wtext/dtext #4280
Conversation
| } | ||
| else | ||
| { | ||
| auto app = appender!S(); |
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.
if args.length == 1 this will be slower I guess
|
@DmitryOlshansky Fixed |
How do you measure it? |
|
|
I really don't see why the auto tester is failing. |
| else | ||
| { | ||
| auto app = appender!S(); | ||
| app.reserve(U.length * S.sizeof); |
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.
Why S.sizeof? As far as I see, it's just an arbitrary number, determined by rule of thumb, and using S.sizeof for this suggests a relation where there is none.
|
Are you sure it's |
Compiler bug. Filed it here: https://issues.dlang.org/show_bug.cgi?id=15992 |
|
Yeah, not sure what I was thinking there. This never worked at CTFE.
It's not |
I see. Yeah, no, let's keep things |
| return result; | ||
| import std.array : appender; | ||
|
|
||
| if (__ctfe) |
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.
appender should work in ctfe thought
|
|
Can someone add the "blocked" tag to this? |
|
One heuristic optimization -- until an argument produces some actual string output, there's no need to fire up an appender. Essentially, you have the single-argument case, no need to copy the string that was just generated and throw that string away. Not sure if it helps or hurts the performance. |
|
See my comment here: #4460 (comment) |
|
Can someone kick the auto-tester? |
| auto app = appender!S(); | ||
|
|
||
| foreach (arg; args) | ||
| app.put(to!S(arg)); |
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.
app.formatValue(fmt, arg); should be used instead.
|
You can add |
What if one of the arguments has a memory unsafe |
d03ad1a to
3927e7e
Compare
|
Ready to go |
Implementations should not be aware of what kind of |
|
Is current implementation always @safe? |
Depends on the implementation of |
|
formatValue is also impure, so that's a no go |
|
LGTM |
|
Auto-merge toggled on |
|
I'd like to have seen an attempt to avoid appender until necessary, but OK. |
Saves about 5 - 7 hnsecs.