Bitcoin Forum
June 23, 2018, 10:30:48 PM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Patch For Minor issue  (Read 944 times)
phantomcircuit
Sr. Member
****
Offline Offline

Activity: 463
Merit: 250


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,
 };
1529793048
Hero Member
*
Offline Offline

Posts: 1529793048

View Profile Personal Message (Offline)

Ignore
1529793048
Reply with quote  #2

1529793048
Report to moderator
1529793048
Hero Member
*
Offline Offline

Posts: 1529793048

View Profile Personal Message (Offline)

Ignore
1529793048
Reply with quote  #2

1529793048
Report to moderator
1529793048
Hero Member
*
Offline Offline

Posts: 1529793048

View Profile Personal Message (Offline)

Ignore
1529793048
Reply with quote  #2

1529793048
Report to moderator
The World's Betting Exchange

Bet with play money. Win real Bitcoin. 5BTC Prize Fund for World Cup 2018.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1554
Merit: 1001


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, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
xenon481
Sr. Member
****
Offline Offline

Activity: 406
Merit: 250



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
Merit: 1013


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!