<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hi Remi,</p>
<p>On 2016-11-07 19:08, Rémi Denis-Courmont wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Well OK, that invalidates my comments. But it still does not seem right.</code></pre>
</blockquote>
<p>I do however agree that it is a hack written for a very specific use-case.</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> At best, you end up with quadratic complexity processing the same lines over
 and over again. But IMHO the worst lies in second guessing
 vlc_stream_ReadLine().</code></pre>
</blockquote>
<p>The above sounds worse than it would actually be in practice, you will potentially “process” the initial line several times, as well as partial data of a line that is longer than the peek size increase (<code>2048</code> in the supplied patch).</p>
<p>In practice this should not happen too often.</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> If you want to peek lines, you should rather use a proper stream wrapper than
 create memory streams over and over again, e.g. (completely untested):</code></pre>
</blockquote>
<p>Indeed, I was however hesitant to add such functionality in the core due to the currently limited request/workarounds present for this functionality.</p>
<p>I would be happy to add support for this in the core (so that everyone can take part of it), but I see no point of having an explicit <em>wrapper</em>; one can implement the functionality directly within <code>src/input/stream.c</code> without having to modify any part of the internal structure.</p>
<p>Do you think it is a good idea to implement the below listed functions in the relevant <em>TU</em> (and exposing them to the world)?</p>
<ul>
<li><code>vlc_stream_PeekReadLine</code></li>
<li><code>vlc_stream_PeekRead</code> (for symmetry purposes)</li>
</ul>
<p>Both functions would behave like their <em>non-peeking</em> counterpart, but not advance the read-offset within the stream. Not sure if the names are descriptive enough, but hopefully their purpose is clear enough to at least discuss the possibility of adding such functions.</p>
<p>Let me know if you find the above applicable, and I can submit a patch for it later this evening.</p>
<p>Best Regards,<br />
Filip</p>
</body>
</html>