From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] Clearing venti arena during install Date: Sun, 26 Mar 2006 16:52:46 -0800 From: geoff@collyer.net In-Reply-To: <7738cc425fad5f8b56882b45df4fdf6d@swtch.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 224222e0-ead1-11e9-9d60-3106f5b1d025 Furthermore, the check for a zero block can be done pretty cheaply (I thought about doing this years ago for v7 Unix). First see if the first word of the buffer is zero; if so, see if the last word is zero; if so, run through the buffer a word at a time, stopping at a non-zero word or end of buffer. In the common (real-life) case, the test of the first word suffices. The word-at-a-time scan can be made to run fairly fast, especially if you have the option of first putting a non-zero word just after the buffer, so that no explicit bounds test is necessary in the loop.