Create a copy or use reference for parameter?
<p>My problem is that I want to return a common substring of two strings s1, s2. Apparently, s1 and s2 are symmetric.</p>

<pre><code>string shortest_common( const string&amp; s1, const string&amp; s2 ) {

}
</code></pre>

<p>There are three possible solutions to this problem that I came up with:  </p>

<ul>
<li>Either make a copy of s1 and s2 </li>
<li>Or swap them, which means I have to sacrifice their const-ness</li>
<li>Or worst, duplicate code!</li>
</ul>

<p>I personally prefer the first case, since intent is to find the shortest-common string not changing s1 or s2. So my question is: Which option is ideal in this case?</p>

<p>Thanks,<br>
Chan</p>
