On Tue, 28 Nov 2006 08:08:04 -0600, Tom Marchant <m42tom- [EMAIL PROTECTED]> wrote:
20 or 25 years ago I made use of a TR-based screen for a branch routine (obviously not in a compiler). My doing that was based on gut feeling rather than any analysis so may not have saved any processing time - I have no way of knowing. But it gave me some appreciation of the technique. >... >First, translate is hardly a blindingly fast instruction. To suggest >that using it rather than 10 tests and branches makes little sense to >me. The efficiency of the technique depends not just on the number of tests but also on their distribution based on the first character and on the the density of matches in the data being scanned. This technique makes sense only if most of the target data falls in the "OTHERWISE" bucket - no hits in the comparisons. And it works best each comparison string starts with a different character. (But "best" may still be worse than doing the multiple comparisons.) > >Second, the number of cases where multiple decisions need to be made >based upon a single one character variable are rare. That's a red herring. The TR simply screens out those comparisons already doomed to failure, and points to they list keys to compare - those starting with the matched character. It's obviously best if there is only one. > >Third, the result is code that is convoluted and diffcult to maintain. > No argument there! Pat O'Keefe ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html

