Re: bitwise operations in obj C
Re: bitwise operations in obj C
- Subject: Re: bitwise operations in obj C
- From: Andrew Farmer <email@hidden>
- Date: Wed, 17 Oct 2007 12:45:26 -0700
On 17 Oct 07, at 10:40, Erfan Aleemullah wrote:
well, not exactly sure, but the program is nearing beta release,
and i'm
trying to eliminate leaks and increase efficiency. So, not exactly
sure if
i *absolutely need to do bit ops here, but it would definitely
help, because
the operation is done everytime the linenumbers increment
themselves - so
when the line number is 100,000, the code would have 'modulo'ed'
100,000
times and as the numbers get large themselves--> eg) 100,000 % 12 =
slightly
expensive yes?
Integer divide/modulo takes a constant amount of time - it doesn't
depend on the size of the operands. It's a little slow as far as
basic mathematical operations go (about 4x as long as a multiply on a
7450 G4, and a pipeline stall), but it's unlikely to be a bottleneck
unless you're doing basically nothing else in the loop body.
There is, incidentally, no way to use bitwise operations to get the
same effect in a general fashion. However, if you aren't using the
line number elsewhere, you may get better performance by avoiding the
modulo entirely:
if(++line_Number == increment) {
line_Number = 0;
// do stuff
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden