<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - support for digital signatures"
href="https://bugs.freedesktop.org/show_bug.cgi?id=16770#c83">Comment # 83</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - support for digital signatures"
href="https://bugs.freedesktop.org/show_bug.cgi?id=16770">bug 16770</a>
from <span class="vcard"><a class="email" href="mailto:aacid@kde.org" title="Albert Astals Cid <aacid@kde.org>"> <span class="fn">Albert Astals Cid</span></a>
</span></b>
<pre>(In reply to Adam Reichold from <a href="show_bug.cgi?id=16770#c81">comment #81</a>)
<span class="quote">> (In reply to Adrian Johnson from <a href="show_bug.cgi?id=16770#c78">comment #78</a>)
> > I agree that the two calls to doGetChars and updateHash should be merged but
> > I don't think a for loop is the best way to process loops where the
> > increment is not exactly the same on each iteration. Maybe something like
> > this:
> >
> > void FormFieldSignature::hashSignedByteRange(SignatureHandler *handler,
> > Goffset start, Goffset len)
> > {
> > const int CHUNK_SIZE = 4096;
> > unsigned char buffer[CHUNK_SIZE];
> > Goffset i = 0;
> > int byte_count = CHUNK_SIZE;
> >
> > doc->getBaseStream()->setPos(start);
> > while (i < len)
> > {
> > if (i + CHUNK_SIZE > len)
> > byte_count = len - i;
> >
> > doc->getBaseStream()->doGetChars(byte_count, buffer);
> > handler->updateHash(buffer, byte_count);
> > i += byte_count;
> > }
> > }
>
> I was thinking of something like
>
> doc->getBaseStream()->setPos(start);
> for (Goffset offset = 0; offset < len; offset += CHUNK_SIZE)
> {
> const int byte_count = min(CHUNK_SIZE, len - offset);
>
> doc->getBaseStream()->doGetChars(byte_count, buffer);
> handler->updateHash(buffer, byte_count);
> }
>
> to make the loop more regular as we don't care if offset > len instead of
> offset == len after the last iteration. (That code was not tested or even
> compiled.)
>
> > I don't mind if we fix all this later. It doesn't have to hold up the
> > initial release.
>
> Maybe if there is some external pressure to release this, but otherwise I'd
> propose polishing it now, since there is a certain momentum not to touch
> working code once it is released.</span >
If we're too picky it may just die in this branch and never be merged :D
<span class="quote">>
> Best regards, Adam.</span ></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>