[Issue 13798] New: Suggestions for classes and methods that can be final
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Nov 30 02:54:58 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13798
Issue ID: 13798
Summary: Suggestions for classes and methods that can be final
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I suggest to add a compiler tip (enabled with warnings) that suggests the
programmer to add a "final" to methods and to classes definitions like this
that don't need to be virtual, to avoid some virtual calls:
class Bar {}
class Foo : Bar {}
void main() {}
This is similar to the -Wsuggest-final-types and -Wsuggest-final-methods
warnings of G++ 5.0, that also tells how many virtual calls are avoided:
/aux/hubicka/firefox/docshell/base/nsDocShell.h:124:0: warning: Declaring type
‘struct nsDocShell’ final would enable devirtualization of 216 calls
[-Wsuggest-final-types]
class nsDocShell : public nsDocLoader,
^
--
More information about the Digitalmars-d-bugs
mailing list