Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d67be61ebe5efaf9c4c11bf168781d678854c966
Commit:     d67be61ebe5efaf9c4c11bf168781d678854c966
Parent:     ba2cf98249795f03792d1409a3b6aaa589ea0745
Author:     Trent Piepho <[EMAIL PROTECTED]>
AuthorDate: Wed Jul 11 20:28:44 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Wed Jul 18 14:24:42 2007 -0300

    V4L/DVB (5832): ir-common: optimize bit extract function
    
    New code is simpler, shorter, compiles to about half the size, and is 2
    to 4 times faster depending on how many bits in the mask are set.
    
    Signed-off-by: Trent Piepho <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/common/ir-functions.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/media/common/ir-functions.c 
b/drivers/media/common/ir-functions.c
index fcb1941..fe447a0 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -107,21 +107,20 @@ void ir_input_keydown(struct input_dev *dev, struct 
ir_input_state *ir,
 }
 
 /* -------------------------------------------------------------------------- 
*/
-
+/* extract mask bits out of data and pack them into the result */
 u32 ir_extract_bits(u32 data, u32 mask)
 {
-       int mbit, vbit;
-       u32 value;
+       u32 vbit = 1, value = 0;
+
+       do {
+           if (mask&1) {
+               if (data&1)
+                       value |= vbit;
+               vbit<<=1;
+           }
+           data>>=1;
+       } while (mask>>=1);
 
-       value = 0;
-       vbit  = 0;
-       for (mbit = 0; mbit < 32; mbit++) {
-               if (!(mask & ((u32)1 << mbit)))
-                       continue;
-               if (data & ((u32)1 << mbit))
-                       value |= (1 << vbit);
-               vbit++;
-       }
        return value;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to