Bitcoin Forum
May 10, 2024, 08:16:31 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Patch For Minor issue  (Read 1095 times)
phantomcircuit (OP)
Sr. Member
****
Offline Offline

Activity: 463
Merit: 252


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

Posts: 1715328991

View Profile Personal Message (Offline)

Ignore
1715328991
Reply with quote  #2

1715328991
Report to moderator
1715328991
Hero Member
*
Offline Offline

Posts: 1715328991

View Profile Personal Message (Offline)

Ignore
1715328991
Reply with quote  #2

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

Activity: 1596
Merit: 1091


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: 2216


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!