[Freeciv-Dev] (PR#8683) specvec iterator patch v2
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8683 >
> [vasc - Sat May 15 02:11:49 2004]:
>
> An iterator macro patch for specvec.
On second thought, it is better to pass a pointer to the element. This
way you can do a write to the current element as well and is faster than
doing a copy for vectors with large element types (i.e. structs).
Index: utility/specvec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/specvec.h,v
retrieving revision 1.5
diff -u -r1.5 specvec.h
--- utility/specvec.h 15 May 2004 00:48:17 -0000 1.5
+++ utility/specvec.h 15 May 2004 02:19:45 -0000
@@ -130,6 +130,17 @@
SPECVEC_FOO(_vector_init)(tthis);
}
+
+#define TYPED_VECTOR_ITERATE(atype, vector, var) { \
+ int myiter; \
+ atype *var; \
+ for (myiter = 0; myiter < (vector)->size; myiter++) { \
+ var = &(vector)->p[myiter]; \
+
+/* Balance for above: */
+#define VECTOR_ITERATE_END }}
+
+
#undef SPECVEC_TAG
#undef SPECVEC_TYPE
#undef SPECVEC_PASTE_
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, (continued)
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Mike Kaufman, 2004/05/05
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Jason Short, 2004/05/05
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Vasco Alexandre da Silva Costa, 2004/05/05
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Vasco Alexandre da Silva Costa, 2004/05/05
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Per Inge Mathisen, 2004/05/06
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Jason Short, 2004/05/06
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Jason Short, 2004/05/06
- [Freeciv-Dev] Re: (PR#8683) remove specvec?, Mike Kaufman, 2004/05/06
- [Freeciv-Dev] (PR#8683) rewrite specvec so it doesn't use athing, Jason Short, 2004/05/12
- [Freeciv-Dev] (PR#8683) specvec iterator patch, Vasco Alexandre da Silva Costa, 2004/05/14
- [Freeciv-Dev] (PR#8683) specvec iterator patch v2,
Vasco Alexandre da Silva Costa <=
- [Freeciv-Dev] (PR#8683) specvec patch v3, Vasco Alexandre da Silva Costa, 2004/05/14
|
|