Messages in this thread | | | Date | Thu, 17 Apr 2003 11:05:30 -0500 | From | Matt Mackall <> | Subject | Re: [PATCH] only use 48-bit lba when necessary |
| |
On Thu, Apr 17, 2003 at 11:24:11AM -0400, Timothy Miller wrote: > > >>Yes, but: > >> > >> if (expr1 && expr2) > >> var = true; > >> else > >> var = false; > >> > >>is usually better turned into something that avoids jumps > >>when it's safe to evaluate both parts unconditionally: > >> > >> var = (expr1 != 0) & (expr2 != 0); > >> > >>or (if you can stand it): > >> > >> var = !!expr1 & !!expr2; > > > >Such ugly transformations are a job for compiler writers and may > >occassionally be acceptable in some critical paths. The IO path, which > >is literally dozens of function calls deep from read()/write() to > >driver methods, does not qualify. > > What's ugly about them?
It doesn't pass the test of "would I use it if I didn't think it was faster?"
As I pointed out, your variant is not faster with a reasonable compiler, only less obvious. And none of this sort of optimization will ever be measurably better in the IO path anyway. But every one of these false optimizations is a barrier to the understanding that will allow real cleanups to make fundamental improvements.
-- Matt Mackall : http://www.selenic.com : of or relating to the moon - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |