<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Virtual methods are not normally inlined by the compiler at all.  In most cases it is impossible by the virtue of virtual dispatch (in some   cases compiler can be smart, but it is up to the compiler).  Conversation about “code bloat” for me is moot here.</div><div class=""><br class=""></div><div class="">Implementing something in header file is just a choice of developer convenience in some cases, as one referenced about HyperKeyLocatorNameChecker.</div><div class=""><br class=""></div><div class="">—</div><div class="">Alex</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Feb 1, 2015, at 8:58 AM, Thompson, Jeff <<a href="mailto:jefft0@remap.ucla.edu" class="">jefft0@remap.ucla.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">Bloat is especially a problem with inline <i class="">virtual</i> functions. This is because every bit of code that instantiates a class has to make a copy of the code for every inline virtual function in that class,
<i class="">even if it doesn't call the function</i>. This is because the instantiated object can be passed to another piece of code which
<i class="">could</i> call one of the virtual functions, so it must be defined. And since it is inline, the code must be defined at the place where the object is instantiated.</div>
<div class=""><br class="">
</div>
<div class="">For example, see the 20-line inline virtual function HyperKeyLocatorNameChecker::check</div>
<div class=""><a href="https://github.com/named-data/ndn-cxx/blob/5ec0ee3b1e90f0b3c44f74430cd080fa583e16dc/src/security/conf/key-locator-checker.hpp#L196" class="">https://github.com/named-data/ndn-cxx/blob/5ec0ee3b1e90f0b3c44f74430cd080fa583e16dc/src/security/conf/key-locator-checker.hpp#L196</a></div>
<div class="">Every piece of code which instantiates a HyperKeyLocatorNameChecker must include the code for HyperKeyLocatorNameChecker::check, even if it does't call it.</div>
<div class=""><br class="">
</div>
<div class="">Of course, if the virtual functions of a class are not inline, but are defined in the class's .cpp file, then this problem is avoided. Therefore, at least inline
<i class="">virtual</i> functions should not be used.</div>
<div class=""><br class="">
</div>
<div class="">- Jeff T</div>
<div class=""><br class="">
</div>
<span id="OLK_SRC_BODY_SECTION" class="">
<div style="font-family: Calibri; font-size: 11pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-top-color: rgb(181, 196, 223);" class="">
<span style="font-weight:bold" class="">From: </span>Junxiao Shi <<a href="mailto:shijunxiao@email.arizona.edu" class="">shijunxiao@email.arizona.edu</a>><br class="">
<span style="font-weight:bold" class="">Date: </span>Saturday, January 31, 2015 at 22:23<br class="">
<span style="font-weight:bold" class="">To: </span>nfd-dev <<a href="mailto:nfd-dev@lists.cs.ucla.edu" class="">nfd-dev@lists.cs.ucla.edu</a>><br class="">
<span style="font-weight:bold" class="">Subject: </span>[Nfd-dev] Avoid inline functions to reduce code size bloat<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" class="">Dear folks
<div class=""><br class="">
</div>
<div class="">Back in June, in issue 1694, I have pointed out that ndn-cxx has a tendency of over-using inline functions.</div>
<div class="">According to <a href="http://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Stop-inlining-code-in-headers" class="">
C++ Dos and Don'ts</a> from Chromium project, using too much inline functions creates additional work for the linker, because every file that includes those headers would emit a version of an inline function in the object file (.o), and the linker has to eliminate
 those duplicates.</div>
<div class="">There's also evidence that inline functions can lead to binary size bloat, which is bad news of devices with small memory or storage, such as home routers and IoT gadgets. Even if ndn-cxx can fit into those devices, bloated binaries will consume precious
 memory space, and reduce available memory for ContentStore.</div>
<div class=""><br class="">
</div>
<div class="">A <a href="http://redmine.named-data.net/issues/1694#note-6" class="">decision was made in 20140708 conference call</a> that we should stop adding new inline functions unless they are trivial getters/setters, but fixing old code is low priority.</div>
<div class="">Of course, if a function is template, and all possible template parameters are not known in advance, it can be inline.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">During the review of issue 2183, I suggested Change Owner to move inline functions into .cpp, as per the decision above.</div>
<div class="">However, this suggestion was rejected.</div>
<div class="">The reply was "whatever you saying. I'm refusing to do change here". No valid reason is given with this reply.</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">To finally resolve this and similar disputes, I request a review on the decision about inline function usage.</div>
<div class="">Please give your opinion about where inline functions should be used, along with necessary reasons and citations.</div>
<div class=""><br class="">
</div>
<div class="">Yours, Junxiao</div>
</div>
</div>
</div>
</span>
</div>

_______________________________________________<br class="">Nfd-dev mailing list<br class=""><a href="mailto:Nfd-dev@lists.cs.ucla.edu" class="">Nfd-dev@lists.cs.ucla.edu</a><br class="">http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev<br class=""></div></blockquote></div><br class=""></body></html>