[Freeciv-Dev] (PR#8656) inline the speclists
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#8656) inline the speclists |
From: |
"Per Inge Mathisen" <per@xxxxxxxxxxx> |
Date: |
Sun, 2 May 2004 09:39:20 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8656 >
This patch makes speclists inline (yes, which I thought impossible until
recently).
It removes 130 lines and adds 57. Removes one file (speclist_c.h). Makes
code more readable and understandable. And a tiny bit faster.
- Per
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.96
diff -u -r1.96 clinet.c
--- client/clinet.c 13 Apr 2004 16:40:00 -0000 1.96
+++ client/clinet.c 2 May 2004 16:35:00 -0000
@@ -480,10 +480,6 @@
#endif
-#define SPECLIST_TAG server
-#define SPECLIST_TYPE struct server
-#include "speclist_c.h"
-
/**************************************************************************
Create the list of servers from the metaserver
The result must be free'd with delete_server_list() when no
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.68
diff -u -r1.68 helpdata.c
--- client/helpdata.c 1 Dec 2003 18:03:40 -0000 1.68
+++ client/helpdata.c 2 May 2004 16:35:01 -0000
@@ -50,9 +50,6 @@
#define SPECLIST_TAG help
#define SPECLIST_TYPE struct help_item
#include "speclist.h"
-#define SPECLIST_TAG help
-#define SPECLIST_TYPE struct help_item
-#include "speclist_c.h"
#define help_list_iterate(helplist, phelp) \
TYPED_LIST_ITERATE(struct help_item, helplist, phelp)
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.165
diff -u -r1.165 tilespec.c
--- client/tilespec.c 29 Apr 2004 15:11:32 -0000 1.165
+++ client/tilespec.c 2 May 2004 16:35:02 -0000
@@ -110,10 +110,6 @@
#define SPECLIST_TYPE struct specfile
#include "speclist.h"
-#define SPECLIST_TAG specfile
-#define SPECLIST_TYPE struct specfile
-#include "speclist_c.h"
-
#define specfile_list_iterate(list, pitem) \
TYPED_LIST_ITERATE(struct specfile, list, pitem)
#define specfile_list_iterate_end LIST_ITERATE_END
@@ -122,10 +118,6 @@
#define SPECLIST_TAG small_sprite
#define SPECLIST_TYPE struct small_sprite
#include "speclist.h"
-
-#define SPECLIST_TAG small_sprite
-#define SPECLIST_TYPE struct small_sprite
-#include "speclist_c.h"
#define small_sprite_list_iterate(list, pitem) \
TYPED_LIST_ITERATE(struct small_sprite, list, pitem)
Index: client/agents/agents.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/agents.c,v
retrieving revision 1.28
diff -u -r1.28 agents.c
--- client/agents/agents.c 18 Apr 2004 10:01:04 -0000 1.28
+++ client/agents/agents.c 2 May 2004 16:35:03 -0000
@@ -59,10 +59,6 @@
#define SPECLIST_TYPE struct call
#include "speclist.h"
-#define SPECLIST_TAG call
-#define SPECLIST_TYPE struct call
-#include "speclist_c.h"
-
#define call_list_iterate(calllist, pcall) \
TYPED_LIST_ITERATE(struct call, calllist, pcall)
#define call_list_iterate_end LIST_ITERATE_END
Index: client/agents/cma_fec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v
retrieving revision 1.18
diff -u -r1.18 cma_fec.c
--- client/agents/cma_fec.c 25 Feb 2004 20:09:50 -0000 1.18
+++ client/agents/cma_fec.c 2 May 2004 16:35:03 -0000
@@ -47,10 +47,6 @@
#define SPECLIST_TYPE struct cma_preset
#include "speclist.h"
-#define SPECLIST_TAG preset
-#define SPECLIST_TYPE struct cma_preset
-#include "speclist_c.h"
-
#define preset_list_iterate(presetlist, ppreset) \
TYPED_LIST_ITERATE(struct cma_preset, presetlist, ppreset)
#define preset_list_iterate_end LIST_ITERATE_END
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.84
diff -u -r1.84 citydlg.c
--- client/gui-gtk-2.0/citydlg.c 2 May 2004 08:00:50 -0000 1.84
+++ client/gui-gtk-2.0/citydlg.c 2 May 2004 16:35:05 -0000
@@ -64,13 +64,7 @@
/* get 'struct dialog_list' and related function */
#define SPECLIST_TAG dialog
#define SPECLIST_TYPE struct city_dialog
-#define SPECLIST_STATIC
#include "speclist.h"
-
-#define SPECLIST_TAG dialog
-#define SPECLIST_TYPE struct city_dialog
-#define SPECLIST_STATIC
-#include "speclist_c.h"
#define dialog_list_iterate(dialoglist, pdialog) \
TYPED_LIST_ITERATE(struct city_dialog, dialoglist, pdialog)
Index: client/gui-gtk-2.0/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cma_fe.c,v
retrieving revision 1.16
diff -u -r1.16 cma_fe.c
--- client/gui-gtk-2.0/cma_fe.c 1 May 2004 17:28:47 -0000 1.16
+++ client/gui-gtk-2.0/cma_fe.c 2 May 2004 16:35:05 -0000
@@ -42,13 +42,7 @@
#define SPECLIST_TAG dialog
#define SPECLIST_TYPE struct cma_dialog
-#define SPECLIST_STATIC1
#include "speclist.h"
-
-#define SPECLIST_TAG dialog
-#define SPECLIST_TYPE struct cma_dialog
-#define SPECLIST_STATIC1
-#include "speclist_c.h"
#define dialog_list_iterate(dialoglist, pdialog) \
TYPED_LIST_ITERATE(struct cma_dialog, dialoglist, pdialog)
Index: client/gui-gtk-2.0/diplodlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/diplodlg.c,v
retrieving revision 1.20
diff -u -r1.20 diplodlg.c
--- client/gui-gtk-2.0/diplodlg.c 1 May 2004 17:28:47 -0000 1.20
+++ client/gui-gtk-2.0/diplodlg.c 2 May 2004 16:35:06 -0000
@@ -59,13 +59,7 @@
#define SPECLIST_TAG dialog
#define SPECLIST_TYPE struct Diplomacy_dialog
-#define SPECLIST_STATIC
#include "speclist.h"
-
-#define SPECLIST_TAG dialog
-#define SPECLIST_TYPE struct Diplomacy_dialog
-#define SPECLIST_STATIC
-#include "speclist_c.h"
#define dialog_list_iterate(dialoglist, pdialog) \
TYPED_LIST_ITERATE(struct Diplomacy_dialog, dialoglist, pdialog)
Index: client/gui-gtk-2.0/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/happiness.c,v
retrieving revision 1.11
diff -u -r1.11 happiness.c
--- client/gui-gtk-2.0/happiness.c 11 May 2003 22:41:41 -0000 1.11
+++ client/gui-gtk-2.0/happiness.c 2 May 2004 16:35:06 -0000
@@ -52,13 +52,7 @@
#define SPECLIST_TAG dialog
#define SPECLIST_TYPE struct happiness_dialog
-#define SPECLIST_STATIC1
#include "speclist.h"
-
-#define SPECLIST_TAG dialog
-#define SPECLIST_TYPE struct happiness_dialog
-#define SPECLIST_STATIC1
-#include "speclist_c.h"
#define dialog_list_iterate(dialoglist, pdialog) \
TYPED_LIST_ITERATE(struct happiness_dialog, dialoglist, pdialog)
Index: client/gui-gtk-2.0/spaceshipdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/spaceshipdlg.c,v
retrieving revision 1.11
diff -u -r1.11 spaceshipdlg.c
--- client/gui-gtk-2.0/spaceshipdlg.c 1 May 2004 17:28:47 -0000 1.11
+++ client/gui-gtk-2.0/spaceshipdlg.c 2 May 2004 16:35:06 -0000
@@ -60,13 +60,7 @@
#define SPECLIST_TAG dialog
#define SPECLIST_TYPE struct spaceship_dialog
-#define SPECLIST_STATIC1
#include "speclist.h"
-
-#define SPECLIST_TAG dialog
-#define SPECLIST_TYPE struct spaceship_dialog
-#define SPECLIST_STATIC1
-#include "speclist_c.h"
#define dialog_list_iterate(dialoglist, pdialog) \
TYPED_LIST_ITERATE(struct spaceship_dialog, dialoglist, pdialog)
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.206
diff -u -r1.206 city.c
--- common/city.c 22 Apr 2004 22:58:28 -0000 1.206
+++ common/city.c 2 May 2004 16:35:08 -0000
@@ -29,11 +29,6 @@
#include "city.h"
-/* get 'struct city_list' functions: */
-#define SPECLIST_TAG city
-#define SPECLIST_TYPE struct city
-#include "speclist_c.h"
-
/* start helper functions for generic_city_refresh */
static int content_citizens(struct player *pplayer);
static void set_tax_income(struct city *pcity);
Index: common/connection.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/connection.c,v
retrieving revision 1.37
diff -u -r1.37 connection.c
--- common/connection.c 14 Jan 2004 11:58:12 -0000 1.37
+++ common/connection.c 2 May 2004 16:35:08 -0000
@@ -43,11 +43,6 @@
#include "connection.h"
-/* get 'struct conn_list' functions: */
-#define SPECLIST_TAG conn
-#define SPECLIST_TYPE struct connection
-#include "speclist_c.h"
-
/* String used for connection.addr and related cases to indicate
* blank/unknown/not-applicable address:
*/
Index: common/diptreaty.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.c,v
retrieving revision 1.19
diff -u -r1.19 diptreaty.c
--- common/diptreaty.c 4 Nov 2003 10:21:56 -0000 1.19
+++ common/diptreaty.c 2 May 2004 16:35:08 -0000
@@ -25,10 +25,6 @@
#include "diptreaty.h"
-#define SPECLIST_TAG clause
-#define SPECLIST_TYPE struct Clause
-#include "speclist_c.h"
-
/**************************************************************************
Returns TRUE iff pplayer could do diplomancy in the game at all.
**************************************************************************/
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.206
diff -u -r1.206 unit.c
--- common/unit.c 29 Apr 2004 19:59:21 -0000 1.206
+++ common/unit.c 2 May 2004 16:35:09 -0000
@@ -30,11 +30,6 @@
#include "unit.h"
-/* get 'struct unit_list' functions: */
-#define SPECLIST_TAG unit
-#define SPECLIST_TYPE struct unit
-#include "speclist_c.h"
-
/***************************************************************
This function calculates the move rate of the unit taking into
account the penalty for reduced hitpoints (affects sea and land
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.80
diff -u -r1.80 diplhand.c
--- server/diplhand.c 6 Mar 2004 11:13:05 -0000 1.80
+++ server/diplhand.c 2 May 2004 16:35:14 -0000
@@ -45,10 +45,6 @@
#define SPECLIST_TYPE struct Treaty
#include "speclist.h"
-#define SPECLIST_TAG treaty
-#define SPECLIST_TYPE struct Treaty
-#include "speclist_c.h"
-
#define treaty_list_iterate(list, p) \
TYPED_LIST_ITERATE(struct Treaty, list, p)
#define treaty_list_iterate_end LIST_ITERATE_END
Index: server/sernet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sernet.c,v
retrieving revision 1.117
diff -u -r1.117 sernet.c
--- server/sernet.c 2 May 2004 08:00:50 -0000 1.117
+++ server/sernet.c 2 May 2004 16:35:15 -0000
@@ -113,10 +113,6 @@
#define SPECLIST_TYPE struct timer
#include "speclist.h"
-#define SPECLIST_TAG timer
-#define SPECLIST_TYPE struct timer
-#include "speclist_c.h"
-
#define PROCESSING_TIME_STATISTICS 0
static int server_accept_connection(int sockfd);
Index: utility/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- utility/Makefile.am 2 May 2004 12:41:53 -0000 1.1
+++ utility/Makefile.am 2 May 2004 16:35:15 -0000
@@ -38,7 +38,6 @@
shared.c \
shared.h \
speclist.h \
- speclist_c.h \
specvec.h \
specvec_c.h \
support.c \
Index: utility/registry.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/registry.c,v
retrieving revision 1.61
diff -u -r1.61 registry.c
--- utility/registry.c 16 Apr 2004 17:08:27 -0000 1.61
+++ utility/registry.c 2 May 2004 16:35:15 -0000
@@ -186,8 +186,6 @@
/* create a 'struct entry_list' and related functions: */
#define SPECLIST_TAG entry
#include "speclist.h"
-#define SPECLIST_TAG entry
-#include "speclist_c.h"
#define entry_list_iterate(entlist, pentry) \
TYPED_LIST_ITERATE(struct entry, entlist, pentry)
@@ -202,8 +200,6 @@
/* create a 'struct section_list' and related functions: */
#define SPECLIST_TAG section
#include "speclist.h"
-#define SPECLIST_TAG section
-#include "speclist_c.h"
#define section_list_iterate(seclist, psection) \
TYPED_LIST_ITERATE(struct section, seclist, psection)
Index: utility/speclist.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/speclist.h,v
retrieving revision 1.5
diff -u -r1.5 speclist.h
--- utility/speclist.h 15 Nov 2002 21:24:30 -0000 1.5
+++ utility/speclist.h 2 May 2004 16:35:15 -0000
@@ -46,15 +46,6 @@
TYPED_LIST_ITERATE(foo_t, foolist, pfoo)
#define foo_list_iterate_end LIST_ITERATE_END
- If you define SPECLIST_STATIC only the functions foo_list_init,
- foo_list_size, foo_list_get, foo_list_insert and foo_list_unlink
- are provided. But these functions will be provided as static
- functions.
-
- If you define SPECLIST_STATIC1 only the functions foo_list_init,
- foo_list_insert and foo_list_unlink are provided. But these
- functions will be provided as static functions.
-
Also, in a single .c file, you should include speclist_c.h,
with the same SPECLIST_TAG and SPECLIST_TYPE defined, to
provide the function implementations.
@@ -75,11 +66,7 @@
#define SPECLIST_TYPE struct SPECLIST_TAG
#endif
-#if defined (SPECLIST_STATIC) || defined (SPECLIST_STATIC1)
-#define SPECLIST_FUNC static
-#else
-#define SPECLIST_FUNC
-#endif
+#define SPECLIST_FUNC static inline
#define SPECLIST_PASTE_(x,y) x ## y
#define SPECLIST_PASTE(x,y) SPECLIST_PASTE_(x,y)
@@ -92,20 +79,47 @@
struct genlist list;
};
-SPECLIST_FUNC void SPECLIST_FOO(_list_init) (SPECLIST_LIST *tthis);
-SPECLIST_FUNC void SPECLIST_FOO(_list_insert) (SPECLIST_LIST *tthis,
SPECLIST_TYPE *pfoo);
-SPECLIST_FUNC void SPECLIST_FOO(_list_unlink) (SPECLIST_LIST *tthis,
SPECLIST_TYPE *pfoo);
+SPECLIST_FUNC void SPECLIST_FOO(_list_init) (SPECLIST_LIST *tthis)
+{
+ genlist_init(&tthis->list);
+}
+
+SPECLIST_FUNC void SPECLIST_FOO(_list_insert) (SPECLIST_LIST *tthis,
SPECLIST_TYPE *pfoo)
+{
+ genlist_insert(&tthis->list, pfoo, 0);
+}
+
+SPECLIST_FUNC void SPECLIST_FOO(_list_unlink) (SPECLIST_LIST *tthis,
SPECLIST_TYPE *pfoo)
+{
+ genlist_unlink(&tthis->list, pfoo);
+}
#if !defined (SPECLIST_STATIC1)
-SPECLIST_FUNC int SPECLIST_FOO(_list_size) (SPECLIST_LIST *tthis);
-SPECLIST_FUNC SPECLIST_TYPE *SPECLIST_FOO(_list_get) (SPECLIST_LIST *tthis,
int index);
+SPECLIST_FUNC int SPECLIST_FOO(_list_size) (SPECLIST_LIST *tthis)
+{
+ return genlist_size(&tthis->list);
+}
+
+SPECLIST_FUNC SPECLIST_TYPE *SPECLIST_FOO(_list_get) (SPECLIST_LIST *tthis,
int index)
+{
+ return (SPECLIST_TYPE *)genlist_get(&tthis->list, index);
+}
#endif
-#if !defined (SPECLIST_STATIC) && !defined (SPECLIST_STATIC1)
-SPECLIST_FUNC void SPECLIST_FOO(_list_insert_back) (SPECLIST_LIST *tthis,
SPECLIST_TYPE *pfoo);
-SPECLIST_FUNC void SPECLIST_FOO(_list_unlink_all) (SPECLIST_LIST *tthis);
-SPECLIST_FUNC void SPECLIST_FOO(_list_sort) (SPECLIST_LIST *tthis, int
(*compar)(const void *, const void *));
-#endif
+SPECLIST_FUNC void SPECLIST_FOO(_list_insert_back) (SPECLIST_LIST *tthis,
SPECLIST_TYPE *pfoo)
+{
+ genlist_insert(&tthis->list, pfoo, -1);
+}
+
+SPECLIST_FUNC void SPECLIST_FOO(_list_unlink_all) (SPECLIST_LIST *tthis)
+{
+ genlist_unlink_all(&tthis->list);
+}
+
+SPECLIST_FUNC void SPECLIST_FOO(_list_sort) (SPECLIST_LIST * tthis, int
(*compar) (const void *, const void *))
+{
+ genlist_sort(&tthis->list, compar);
+}
#undef SPECLIST_TAG
#undef SPECLIST_TYPE
@@ -114,5 +128,3 @@
#undef SPECLIST_LIST
#undef SPECLIST_FOO
#undef SPECLIST_FUNC
-#undef SPECLIST_STATIC
-#undef SPECLIST_STATIC1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#8656) inline the speclists,
Per Inge Mathisen <=
|
|