[Mono-dev] String class speed improvements (UPDATE)

Joshua Tauberer jit at occams.info
Sun Nov 26 14:18:05 EST 2006


Marek Safar wrote:
> Thanks to Paulo's recommendations here is the
> updated version of my original patch.
...
> +				while (ptr != end_ptr) {
> +					if (*ptr == value_32)
> +						return (int)(ptr - start);
> +					if (ptr[1] == value_32)
> +						return (int)(ptr - start + 1);
> +					if (ptr[2] == value_32)
> +						return (int)(ptr - start + 2);
> +					if (ptr[3] == value_32)
> +						return (int)(ptr - start + 3);
> +					if (ptr[4] == value_32)
> +						return (int)(ptr - start + 4);
> +					if (ptr[5] == value_32)
> +						return (int)(ptr - start + 5);
> +					if (ptr[6] == value_32)
> +						return (int)(ptr - start + 6);
> +					if (ptr[7] == value_32)
> +						return (int)(ptr - start + 7);
> +
> +					ptr += 8;
> +				}

Can't we get mcs to optimize loops like this rather than putting it in
code?  (Am I right in understanding this as eliminating 7/8ths of the
addition operations?)

-- 
- Josh Tauberer

http://razor.occams.info

"Yields falsehood when preceded by its quotation!  Yields
falsehood when preceded by its quotation!" Achilles to
Tortoise (in "Gödel, Escher, Bach" by Douglas Hofstadter)



More information about the Mono-devel-list mailing list