<div dir="ltr">Hi Fabio,<div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 23, 2018 at 12:11 PM, Fabio Niephaus <span dir="ltr"><<a href="mailto:lists@fniephaus.com" target="_blank">lists@fniephaus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr">Hi all,<div><br></div><div>I noticed that BitBlt's primitiveDisplayString fails relatively often and then found out that it's sometimes called to draw empty strings.</div><div><br></div><div>`(ByteString allInstances select: [:ea | ea isEmpty]) size` revealed that there are 2245 empty strings in my image and I assume some of them must be either in the FrameRateMorph morph or in the Clock morph.<br></div><div><br></div><div>Anyway...looking at BitBlt>>#primDisplayString:<wbr>from:to:map:xTable:kern:, the fallback code basically does nothing if stopIndex is zero (`startIndex to: stopIndex do: ...`) which makes sense.</div><div><br></div><div>What I think doesn't make sense is that the primitive fails in the first place. Instead of failing if stopIndex is not greater 0, I would suggest to use: `stopIndex < 1 ifTrue: [^ interpreterProxy pop: 6].` which cleans up the stack, leaves the receiver, and returns early.</div><div><br></div><div>Let me know what you think!</div></div></blockquote><div><br></div><div>I don't object.  So you suggest the following?</div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>((interpreterProxy isArray: xTable)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span> and: [(interpreterProxy isArray: glyphMap)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span> and: [(interpreterProxy slotSizeOf: glyphMap) = 256</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span> and: [(interpreterProxy isBytes: sourceString)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span> and: [startIndex > 0</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span> and: [stopIndex > 0</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span> and: [stopIndex <= (interpreterProxy byteSizeOf: sourceString)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span> and: [(self loadBitBltFrom: bbObj)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span> and: [combinationRule ~= 30 "these two need extra source alpha"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span> and: [combinationRule ~= 31]]]]]]]]]) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>[^interpreterProxy primitiveFail].</div><div><br></div><div>=></div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>((interpreterProxy isArray: xTable)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span> and: [(interpreterProxy isArray: glyphMap)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span> and: [(interpreterProxy slotSizeOf: glyphMap) = 256</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span> and: [(interpreterProxy isBytes: sourceString)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span> and: [startIndex > 0</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span> <b>and: [stopIndex >= 0 "to avoid failing for empty strings..."</b></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span> and: [stopIndex <= (interpreterProxy byteSizeOf: sourceString)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span> and: [(self loadBitBltFrom: bbObj)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span> and: [combinationRule ~= 30 "these two need extra source alpha"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span> and: [combinationRule ~= 31]]]]]]]]]) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>[^interpreterProxy primitiveFail].</div><div> </div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>stopIndex = 0 ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">          </span>[^interpreterProxy pop: 6. "the string is empty; pop args, return rcvr"].</div></div><div></div></div><div class="gmail_extra"><br></div>Any other opinions either way?</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>