]> git.pond.sub.org Git - empserver/commitdiff
(getcontact, putcontact): Remove the bit shifting that was in the
authorRon Koenderink <rkoenderink@yahoo.ca>
Fri, 18 Nov 2005 22:58:54 +0000 (22:58 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Fri, 18 Nov 2005 22:58:54 +0000 (22:58 +0000)
function to save space.  opt_LOSE_CONTACT changes negated
any space saving.

src/lib/common/nat.c

index 1253955d8175cea1480a93ae55e980566df9d7ad..ef89833408a80cfbb55ccafb2bebf17c52cb93c3 100644 (file)
@@ -133,17 +133,7 @@ agecontact(struct natstr *np)
 int
 getcontact(struct natstr *np, natid them)
 {
-    int contact;
-
-    if (opt_LOSE_CONTACT) {
-       contact = np->nat_contact[them];
-    } else {
-       int ind = them / 16;
-       int shift = (them % 16);
-
-       contact = (np->nat_contact[ind] >> shift) & 1;
-    }
-    return contact;
+    return np->nat_contact[them];
 }
 
 void
@@ -173,18 +163,6 @@ putreject(struct natstr *np, natid them, int how, int what)
 void
 putcontact(struct natstr *np, natid them, int contact)
 {
-    if (opt_LOSE_CONTACT) {
-       if (np->nat_contact[them] > contact)
-           return;
+    if (np->nat_contact[them] < contact)
        np->nat_contact[them] = contact;
-    } else {
-       int ind = them / 16;
-       int shift = them % 16;
-       int new = np->nat_contact[ind];
-       if (contact)
-           contact = 1;
-       new &= ~(1 << shift);
-       new |= (contact << shift);
-       np->nat_contact[ind] = new;
-    }
 }