On Tue, 11 Oct 2005, linux-os (Dick Johnson) wrote: > On Tue, 11 Oct 2005, Paul Jackson wrote: > > > Alan asked: > >> But why do people go to the > >> effort of confusing readers by using "^" instead of "!="? > > > > My guess - eor (^) was quicker than not-equal (!=) on a PDP-11. > > > > That code fragment for checking uid's has been around a -long- > > time, if my memory serves me. > > > > It's gotten to be like the infamous "!!" boolean conversion > > operator, a bit of vernacular that would be harder to read if > > recoded using modern coding style.
Surely Linux uses entirely original code, with no hangovers from the original AT&T Unix... Besides, to the best of my recollection, the two operations are equal in speed on a PDP-11. "!!" makes sense as an idiom. But "^" for "!=" doesn't, at least not in this context. > Also, at one time, people used to spend a lot of time > minimizing the number of CPU cycles used in the code. > > For instance, when it's appropriate, using XOR makes the > resulting generated code simpler and usually faster: ... Yes, sometimes XOR can yield simpler object code. But not in cases like this, where it's part of a Boolean test: if (... && (a1^b1) && (a2^b2) && (a3^b3)) ... On any architecture I know of, "^" and "!=" would be equally efficient here. Alan Stern ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel