Bitcoin Forum
December 09, 2016, 11:27:51 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Patch For Minor issue  (Read 854 times)
phantomcircuit
Sr. Member
****
Offline Offline

Activity: 463


View Profile
February 14, 2011, 10: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,
 };
1481326071
Hero Member
*
Offline Offline

Posts: 1481326071

View Profile Personal Message (Offline)

Ignore
1481326071
Reply with quote  #2

1481326071
Report to moderator
1481326071
Hero Member
*
Offline Offline

Posts: 1481326071

View Profile Personal Message (Offline)

Ignore
1481326071
Reply with quote  #2

1481326071
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481326071
Hero Member
*
Offline Offline

Posts: 1481326071

View Profile Personal Message (Offline)

Ignore
1481326071
Reply with quote  #2

1481326071
Report to moderator
1481326071
Hero Member
*
Offline Offline

Posts: 1481326071

View Profile Personal Message (Offline)

Ignore
1481326071
Reply with quote  #2

1481326071
Report to moderator
1481326071
Hero Member
*
Offline Offline

Posts: 1481326071

View Profile Personal Message (Offline)

Ignore
1481326071
Reply with quote  #2

1481326071
Report to moderator
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


View Profile
February 14, 2011, 11: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.


Jeff Garzik, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
xenon481
Sr. Member
****
Offline Offline

Activity: 406



View Profile
February 14, 2011, 11: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.

Tips Appreciated: 171TQ2wJg7bxj2q68VNibU75YZB22b7ZDr
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
February 15, 2011, 12:31:10 AM
 #4

I agree with jgarzik:  the do-nothing << 0 is basically a comment saying "this is a bit-field."

How often do you get the chance to work on a potentially world-changing project?
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!