Thank you Kiste, your advices are well received. My background is more
in Pascal and very little in C. I like both constructions and I will
keep this one:

> procedure s_temp_18B20_CRC([...], byte in max_crc_errors) is
> var byte i = 0
>   repeat
>     [...]
>     i = i + 1
>   until ( GOOD_crc == 0 ) | (i == max_crc_errors)

Vasi


On Dec 15, 11:51 am, Oliver Seitz <[email protected]> wrote:
> Totally unrelated, but some other optimization...
>
> > procedure s_temp_18B20_CRC([...], byte in max_crc_errors) is
> > var byte i = 0
> >   repeat
> >     [...]
> >     i = i + 1
> >   until ( GOOD_crc == 0 ) | (i == max_crc_errors)
>
> Comparisons between two variables take more code space, more data space and 
> more execution time than comparisons between a variable and a constant. And, 
> a comparison between a variable and "zero" takes even fewer code space and 
> execution time than a comparison between a variable and any other constant. 
> So this one would be more efficient:
>
>   procedure s_temp_18B20_CRC([...], byte in max_crc_errors) is
>   var byte crc_retries
>   crc_retries=max_crc_errors
>
>   repeat
>     [...]
>     crc_retries = crc_retries - 1
>   until ( GOOD_crc == 0 ) | (crc_retries == 0)
>
> You don't have to change it if it's more readable the other way, the 
> difference is not very big for byte variables. Just my bit of academic 
> smartassing...
>
> Greets,
> Kiste

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to