summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-21 00:27:31 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-21 00:27:31 -0400
commit79ac892af5ad07803e887b99bcecbb3bf403b75e (patch)
tree10c04e1a4c6d1e7ccad9a39c42df63d8dc083611
parent8866250d8feb9507180b26d03250f7477ef1666a (diff)
downloaddimension-79ac892af5ad07803e887b99bcecbb3bf403b75e.tar.xz
Change initial array capacity to 2.
A quick experiment shows that arrays average less than 2 elements, and this helps a bit with the memory-hogginess of the parser.
-rw-r--r--libdimension/dimension/array.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/libdimension/dimension/array.h b/libdimension/dimension/array.h
index 85543cc..b718021 100644
--- a/libdimension/dimension/array.h
+++ b/libdimension/dimension/array.h
@@ -35,16 +35,6 @@ typedef struct {
size_t obj_size, length, capacity;
} dmnsn_array;
-/* Delete an array */
-DMNSN_INLINE void
-dmnsn_delete_array(dmnsn_array *array)
-{
- if (array) {
- dmnsn_free(array->ptr);
- dmnsn_free(array);
- }
-}
-
/* Array allocation */
DMNSN_INLINE dmnsn_array *
dmnsn_new_array(size_t obj_size)
@@ -52,7 +42,7 @@ dmnsn_new_array(size_t obj_size)
dmnsn_array *array = (dmnsn_array *)dmnsn_malloc(sizeof(dmnsn_array));
array->obj_size = obj_size;
array->length = 0;
- array->capacity = 4; /* Start with capacity of 4 */
+ array->capacity = 2; /* Start with capacity of 2 */
/* Allocate the memory */
array->ptr = dmnsn_malloc(array->capacity*array->obj_size);
@@ -60,6 +50,16 @@ dmnsn_new_array(size_t obj_size)
return array;
}
+/* Delete an array */
+DMNSN_INLINE void
+dmnsn_delete_array(dmnsn_array *array)
+{
+ if (array) {
+ dmnsn_free(array->ptr);
+ dmnsn_free(array);
+ }
+}
+
/* Get the size of the array */
DMNSN_INLINE size_t
dmnsn_array_size(const dmnsn_array *array)