Просмотр исходного кода

Merge branch 'master' into next

* master:
  Allow inlining list_*
  chanset_unlink is simply list_delete ...
Bryan Drewery 7 лет назад
Родитель
Сommit
9be27b7f0e
3 измененных файлов с 31 добавлено и 49 удалено
  1. 1 19
      src/mod/channels.mod/channels.cc
  2. 0 27
      src/userent.cc
  3. 30 3
      src/users.h

+ 1 - 19
src/mod/channels.mod/channels.cc

@@ -595,24 +595,6 @@ bool ismasked(masklist *m, const char *username)
   return 0;
 }
 
-/* Unlink chanset element from chanset list.
- */
-static inline bool chanset_unlink(struct chanset_t *chan)
-{
-  struct chanset_t *c_old = NULL;
-
-  for (struct chanset_t *c = chanset; c; c_old = c, c = c->next) {
-    if (c == chan) {
-      if (c_old)
-	c_old->next = c->next;
-      else
-	chanset = c->next;
-      return 1;
-    }
-  }
-  return 0;
-}
-
 /* Completely removes a channel.
  *
  * This includes the removal of all channel-bans, -exempts and -invites, as
@@ -624,7 +606,7 @@ void remove_channel(struct chanset_t *chan)
      irc_log(chan, "Parting");
      /* Remove the channel from the list, so that noone can pull it
         away from under our feet during the check_part() call. */
-     chanset_unlink(chan);
+     list_delete((struct list_type **) &chanset, (struct list_type *) chan);
 
     /* Using chan->name is important here, especially for !chans <cybah> */
     if (!conf.bot->hub && shouldjoin(chan) && chan->name[0])

+ 0 - 27
src/userent.cc

@@ -1050,33 +1050,6 @@ struct user_entry_type USERENTRY_HOSTS =
   "HOSTS"
 };
 
-bool list_append(struct list_type **h, struct list_type *i)
-{
-  for (; *h; h = &((*h)->next))
-    ;
-  *h = i;
-  return 1;
-}
-
-bool list_delete(struct list_type **h, struct list_type *i)
-{
-  for (; *h; h = &((*h)->next))
-    if (*h == i) {
-      *h = i->next;
-      return 1;
-    }
-  return 0;
-}
-
-bool list_contains(struct list_type *h, struct list_type *i)
-{
-  for (; h; h = h->next)
-    if (h == i) {
-      return 1;
-    }
-  return 0;
-}
-
 bool add_entry_type(struct user_entry_type *type)
 {
   struct userrec *u = NULL;

+ 30 - 3
src/users.h

@@ -21,9 +21,36 @@ struct list_type {
     	(b)->next = *(a);						\
 	*(a) = (b);							\
 }
-bool list_append(struct list_type **, struct list_type *);
-bool list_delete(struct list_type **, struct list_type *);
-bool list_contains(struct list_type *, struct list_type *);
+
+static inline bool
+list_append(struct list_type **h, struct list_type *i)
+{
+  for (; *h; h = &((*h)->next))
+    ;
+  *h = i;
+  return 1;
+}
+
+static inline bool
+list_delete(struct list_type **h, struct list_type *i)
+{
+  for (; *h; h = &((*h)->next))
+    if (*h == i) {
+      *h = i->next;
+      return 1;
+    }
+  return 0;
+}
+
+static inline bool
+list_contains(struct list_type *h, struct list_type *i)
+{
+  for (; h; h = h->next)
+    if (h == i) {
+      return 1;
+    }
+  return 0;
+}
 
 namespace bd {
   class Stream;