Author

Topic: Patch For Minor issue (Read 1116 times)

legendary
Activity: 1652
Merit: 2301
Chief Scientist
February 14, 2011, 07:31:10 PM
#4
I agree with jgarzik:  the do-nothing << 0 is basically a comment saying "this is a bit-field."
sr. member
Activity: 406
Merit: 250
February 14, 2011, 06:27:39 PM
#3
Since it is an enum, there are no significant performance differences.

Additionally, any decent compiler (with optimizations turned on) would optimize both the edited and non-edited lines of code to be the exact same thing since they are all constants.
legendary
Activity: 1596
Merit: 1100
February 14, 2011, 06:24:07 PM
#2
diff --git a/net.h b/net.h
index f070816..205991f 100644
--- a/net.h
+++ b/net.h
@@ -16,7 +16,7 @@ inline unsigned short GetDefaultPort() { return fTestNet ? htons(18333) : htons(
 static const unsigned int PUBLISH_HOPS = 5;
 enum
 {
-    NODE_NETWORK = (1 << 0),
+    NODE_NETWORK = 1,
 };


The code is correct as-is.   This is the normal way someone defines bitmap constants, and is found throughout the Linux kernel among other places.

In the future, you would probably see
Code:
enum {
     NODE_NETWORK      = (1 << 0),
     NODE_FOO          = (1 << 1),
     NODE_BAR          = (1 << 2),
};

etc.

sr. member
Activity: 463
Merit: 252
February 14, 2011, 05:53:15 PM
#1
diff --git a/net.h b/net.h
index f070816..205991f 100644
--- a/net.h
+++ b/net.h
@@ -16,7 +16,7 @@ inline unsigned short GetDefaultPort() { return fTestNet ? htons(18333) : htons(
 static const unsigned int PUBLISH_HOPS = 5;
 enum
 {
-    NODE_NETWORK = (1 << 0),
+    NODE_NETWORK = 1,
 };
Jump to: