summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-4.6-PATCHES/patch-40-LESwaps
blob: edc5adb1fd4c5ebe4670d7c3072e2fa5948c9aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Index: LESwaps.h
===================================================================
--- LESwaps.h	(revision 23041)
+++ LESwaps.h	(working copy)
@@ -1,6 +1,7 @@
+
 /*
  *
- * (C) Copyright IBM Corp. 1998-2010 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
  *
  */
 
@@ -22,7 +23,7 @@
  *
  * @stable ICU 2.8
  */
-#define SWAPW(value) LESwaps::swapWord((le_uint16)(value))
+#define SWAPW(value) LESwaps::swapWord((const le_uint16 &) (value))
 
 /**
  * A convenience macro which invokes the swapLong member function
@@ -30,7 +31,7 @@
  *
  * @stable ICU 2.8
  */
-#define SWAPL(value) LESwaps::swapLong((le_uint32)(value))
+#define SWAPL(value) LESwaps::swapLong((const le_uint32 &) (value))
 
 /**
  * This class is used to access data which stored in big endian order
@@ -54,9 +55,11 @@
      *
      * @stable ICU 2.8
      */
-    static le_uint16 swapWord(le_uint16 value)
+    static le_uint16 swapWord(const le_uint16 &value)
     {
-        return (le_uint16)((value << 8) | (value >> 8));
+        const le_uint8 *p = (const le_uint8 *) &value;
+
+        return ((p[0] << 8) + p[1]);
     };
 
     /**
@@ -69,13 +72,11 @@
      *
      * @stable ICU 2.8
      */
-    static le_uint32 swapLong(le_uint32 value)
+    static le_uint32 swapLong(const le_uint32 &value)
     {
-        return (le_uint32)(
-            (value << 24) |
-            ((value << 8) & 0xff0000) |
-            ((value >> 8) & 0xff00) |
-            (value >> 24));
+        const le_uint8 *p = (const le_uint8 *) &value;
+
+        return ((p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3]);
     };
 
 private: