<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Bloat is especially a problem with inline <i>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>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>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><br>
</div>
<div>For example, see the 20-line inline virtual function HyperKeyLocatorNameChecker::check</div>
<div><a href="https://github.com/named-data/ndn-cxx/blob/5ec0ee3b1e90f0b3c44f74430cd080fa583e16dc/src/security/conf/key-locator-checker.hpp#L196">https://github.com/named-data/ndn-cxx/blob/5ec0ee3b1e90f0b3c44f74430cd080fa583e16dc/src/security/conf/key-locator-checker.hpp#L196</a></div>
<div>Every piece of code which instantiates a HyperKeyLocatorNameChecker must include the code for HyperKeyLocatorNameChecker::check, even if it does't call it.</div>
<div><br>
</div>
<div>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>virtual</i> functions should not be used.</div>
<div><br>
</div>
<div>- Jeff T</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Junxiao Shi <<a href="mailto:shijunxiao@email.arizona.edu">shijunxiao@email.arizona.edu</a>><br>
<span style="font-weight:bold">Date: </span>Saturday, January 31, 2015 at 22:23<br>
<span style="font-weight:bold">To: </span>nfd-dev <<a href="mailto:nfd-dev@lists.cs.ucla.edu">nfd-dev@lists.cs.ucla.edu</a>><br>
<span style="font-weight:bold">Subject: </span>[Nfd-dev] Avoid inline functions to reduce code size bloat<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">Dear folks
<div><br>
</div>
<div>Back in June, in issue 1694, I have pointed out that ndn-cxx has a tendency of over-using inline functions.</div>
<div>According to <a href="http://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Stop-inlining-code-in-headers">
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>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><br>
</div>
<div>A <a href="http://redmine.named-data.net/issues/1694#note-6">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>Of course, if a function is template, and all possible template parameters are not known in advance, it can be inline.</div>
<div><br>
</div>
<div><br>
</div>
<div>During the review of issue 2183, I suggested Change Owner to move inline functions into .cpp, as per the decision above.</div>
<div>However, this suggestion was rejected.</div>
<div>The reply was "whatever you saying. I'm refusing to do change here". No valid reason is given with this reply.</div>
<div><br>
</div>
<div><br>
</div>
<div>To finally resolve this and similar disputes, I request a review on the decision about inline function usage.</div>
<div>Please give your opinion about where inline functions should be used, along with necessary reasons and citations.</div>
<div><br>
</div>
<div>Yours, Junxiao</div>
</div>
</div>
</div>
</span>
</body>
</html>