[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Use larger_vector instead of Fmake_vector and bcopy
From: |
Dmitry Antipov |
Subject: |
Use larger_vector instead of Fmake_vector and bcopy |
Date: |
Fri, 05 Oct 2007 13:12:24 +0400 |
User-agent: |
Thunderbird 2.0.0.5 (X11/20070719) |
Hello,
this cleanup patch tries to utilize larger_vector instead of Fmake_vector &
bcopy
where possible, thus avoiding few code duplications.
Dmitry
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/src/ChangeLog,v
retrieving revision 1.5912
diff -u -r1.5912 ChangeLog
--- ChangeLog 4 Oct 2007 16:57:53 -0000 1.5912
+++ ChangeLog 5 Oct 2007 05:28:13 -0000
@@ -1,3 +1,14 @@
+2007-10-05 Dmitry Antipov <address@hidden>
+
+ * buffer.c (add_overlay_mod_hooklist):
+ * ccl.c (Fregister_ccl_program, Fregister_code_conversion_map):
+ * fontset.c (make_fontset):
+ * keyboard.c (GROW_RAW_KEYBUF, menu_bar_items, menu_bar_item)
+ (append_tool_bar_item):
+ * macmenu.c (grow_menu_items):
+ * w32menu.c (grow_menu_items):
+ * xmenu.c (grow_menu_items): use larger_vector.
+
2007-10-04 Juanma Barranquero <address@hidden>
* image.c (syms_of_image) <image-types>: Fix typo in docstring.
Index: buffer.c
===================================================================
RCS file: /sources/emacs/emacs/src/buffer.c,v
retrieving revision 1.534
diff -u -r1.534 buffer.c
--- buffer.c 2 Oct 2007 21:09:17 -0000 1.534
+++ buffer.c 5 Oct 2007 05:28:13 -0000
@@ -4217,15 +4217,8 @@
int oldsize = XVECTOR (last_overlay_modification_hooks)->size;
if (last_overlay_modification_hooks_used == oldsize)
- {
- Lisp_Object old;
- old = last_overlay_modification_hooks;
- last_overlay_modification_hooks
- = Fmake_vector (make_number (oldsize * 2), Qnil);
- bcopy (XVECTOR (old)->contents,
- XVECTOR (last_overlay_modification_hooks)->contents,
- sizeof (Lisp_Object) * oldsize);
- }
+ last_overlay_modification_hooks = larger_vector
+ (last_overlay_modification_hooks, oldsize * 2, Qnil);
AREF (last_overlay_modification_hooks,
last_overlay_modification_hooks_used++) = functionlist;
AREF (last_overlay_modification_hooks,
last_overlay_modification_hooks_used++) = overlay;
}
Index: ccl.c
===================================================================
RCS file: /sources/emacs/emacs/src/ccl.c,v
retrieving revision 1.99
diff -u -r1.99 ccl.c
--- ccl.c 13 Aug 2007 13:41:13 -0000 1.99
+++ ccl.c 5 Oct 2007 05:28:13 -0000
@@ -2348,16 +2348,8 @@
}
if (idx == len)
- {
- /* Extend the table. */
- Lisp_Object new_table;
- int j;
-
- new_table = Fmake_vector (make_number (len * 2), Qnil);
- for (j = 0; j < len; j++)
- ASET (new_table, j, AREF (Vccl_program_table, j));
- Vccl_program_table = new_table;
- }
+ /* Extend the table. */
+ Vccl_program_table = larger_vector (Vccl_program_table, len * 2, Qnil);
{
Lisp_Object elt;
@@ -2416,15 +2408,8 @@
}
if (i == len)
- {
- Lisp_Object new_vector = Fmake_vector (make_number (len * 2), Qnil);
- int j;
-
- for (j = 0; j < len; j++)
- AREF (new_vector, j)
- = AREF (Vcode_conversion_map_vector, j);
- Vcode_conversion_map_vector = new_vector;
- }
+ Vcode_conversion_map_vector = larger_vector
+ (Vcode_conversion_map_vector, len * 2, Qnil);
index = make_number (i);
Fput (symbol, Qcode_conversion_map, map);
Index: fontset.c
===================================================================
RCS file: /sources/emacs/emacs/src/fontset.c,v
retrieving revision 1.107
diff -u -r1.107 fontset.c
--- fontset.c 29 Aug 2007 05:27:55 -0000 1.107
+++ fontset.c 5 Oct 2007 05:28:13 -0000
@@ -391,15 +391,7 @@
while (!NILP (AREF (Vfontset_table, id))) id++;
if (id + 1 == size)
- {
- Lisp_Object tem;
- int i;
-
- tem = Fmake_vector (make_number (size + 8), Qnil);
- for (i = 0; i < size; i++)
- AREF (tem, i) = AREF (Vfontset_table, i);
- Vfontset_table = tem;
- }
+ Vfontset_table = larger_vector (Vfontset_table, size + 8, Qnil);
fontset = Fmake_char_table (Qfontset, Qnil);
Index: keyboard.c
===================================================================
RCS file: /sources/emacs/emacs/src/keyboard.c,v
retrieving revision 1.916
diff -u -r1.916 keyboard.c
--- keyboard.c 23 Sep 2007 02:02:42 -0000 1.916
+++ keyboard.c 5 Oct 2007 05:28:14 -0000
@@ -160,14 +160,7 @@
#define GROW_RAW_KEYBUF
\
if (raw_keybuf_count == XVECTOR (raw_keybuf)->size) \
- { \
- int newsize = 2 * XVECTOR (raw_keybuf)->size; \
- Lisp_Object new; \
- new = Fmake_vector (make_number (newsize), Qnil); \
- bcopy (XVECTOR (raw_keybuf)->contents, XVECTOR (new)->contents, \
- raw_keybuf_count * sizeof (Lisp_Object)); \
- raw_keybuf = new; \
- }
+ raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil) \
/* Number of elements of this_command_keys
that precede this key sequence. */
@@ -7588,13 +7581,7 @@
/* Add nil, nil, nil, nil at the end. */
i = menu_bar_items_index;
if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
- {
- Lisp_Object tem;
- tem = Fmake_vector (make_number (2 * i), Qnil);
- bcopy (XVECTOR (menu_bar_items_vector)->contents,
- XVECTOR (tem)->contents, i * sizeof (Lisp_Object));
- menu_bar_items_vector = tem;
- }
+ menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
/* Add this item. */
XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
@@ -7666,14 +7653,7 @@
{
/* If vector is too small, get a bigger one. */
if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
- {
- Lisp_Object tem;
- tem = Fmake_vector (make_number (2 * i), Qnil);
- bcopy (XVECTOR (menu_bar_items_vector)->contents,
- XVECTOR (tem)->contents, i * sizeof (Lisp_Object));
- menu_bar_items_vector = tem;
- }
-
+ menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i,
Qnil);
/* Add this item. */
XVECTOR (menu_bar_items_vector)->contents[i++] = key;
XVECTOR (menu_bar_items_vector)->contents[i++]
@@ -8442,16 +8422,8 @@
/* Enlarge tool_bar_items_vector if necessary. */
if (ntool_bar_items + TOOL_BAR_ITEM_NSLOTS
>= XVECTOR (tool_bar_items_vector)->size)
- {
- Lisp_Object new_vector;
- int old_size = XVECTOR (tool_bar_items_vector)->size;
-
- new_vector = Fmake_vector (make_number (2 * old_size), Qnil);
- bcopy (XVECTOR (tool_bar_items_vector)->contents,
- XVECTOR (new_vector)->contents,
- old_size * sizeof (Lisp_Object));
- tool_bar_items_vector = new_vector;
- }
+ tool_bar_items_vector = larger_vector
+ (tool_bar_items_vector, 2 * XVECTOR (tool_bar_items_vector)->size, Qnil);
/* Append entries from tool_bar_item_properties to the end of
tool_bar_items_vector. */
Index: macmenu.c
===================================================================
RCS file: /sources/emacs/emacs/src/macmenu.c,v
retrieving revision 1.64
diff -u -r1.64 macmenu.c
--- macmenu.c 29 Aug 2007 05:27:54 -0000 1.64
+++ macmenu.c 5 Oct 2007 05:28:14 -0000
@@ -347,15 +347,8 @@
static void
grow_menu_items ()
{
- Lisp_Object old;
- int old_size = menu_items_allocated;
- old = menu_items;
-
menu_items_allocated *= 2;
-
- menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
- bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
- old_size * sizeof (Lisp_Object));
+ menu_items = larger_vector (menu_items, menu_items_allocated, Qnil);
}
/* Begin a submenu. */
Index: w32menu.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32menu.c,v
retrieving revision 1.92
diff -u -r1.92 w32menu.c
--- w32menu.c 29 Aug 2007 05:27:57 -0000 1.92
+++ w32menu.c 5 Oct 2007 05:28:14 -0000
@@ -318,14 +318,8 @@
static void
grow_menu_items ()
{
- Lisp_Object old;
- int old_size = menu_items_allocated;
- old = menu_items;
-
menu_items_allocated *= 2;
- menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
- bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
- old_size * sizeof (Lisp_Object));
+ menu_items = larger_vector (menu_items, menu_items_allocated, Qnil);
}
/* Begin a submenu. */
Index: xmenu.c
===================================================================
RCS file: /sources/emacs/emacs/src/xmenu.c,v
retrieving revision 1.323
diff -u -r1.323 xmenu.c
--- xmenu.c 12 Sep 2007 07:23:12 -0000 1.323
+++ xmenu.c 5 Oct 2007 05:28:14 -0000
@@ -354,15 +354,8 @@
static void
grow_menu_items ()
{
- Lisp_Object old;
- int old_size = menu_items_allocated;
- old = menu_items;
-
menu_items_allocated *= 2;
-
- menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
- bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
- old_size * sizeof (Lisp_Object));
+ menu_items = larger_vector (menu_items, menu_items_allocated, Qnil);
}
/* Begin a submenu. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Use larger_vector instead of Fmake_vector and bcopy,
Dmitry Antipov <=