[Issue 14975] New: DMD refuses to inline even trivial struct constructors
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Aug 28 17:11:38 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14975
Issue ID: 14975
Summary: DMD refuses to inline even trivial struct constructors
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: thomas.bockman at gmail.com
While doing some refactoring and updating
[CheckedInt](https://github.com/tsbockman/CheckedInt) for DMD 2.068, I have
discovered one major source of slowness: DMD cannot inline even trivial struct
constructors:
// Error: constructor foo.this cannot inline function
struct foo {
int bar;
pragma(inline, true) this(int bar) {
this.bar = bar;
}
}
Refactoring my code to reduce the use of struct constructors yielded a 2x speed
boost. The workaround is stupidly simple, though ugly:
struct foo {
int bar;
pragma(inline, true) static auto inline_cons(int bar) {
foo ret = void;
ret.bar = bar;
return ret;
}
}
--
More information about the Digitalmars-d-bugs
mailing list