changeset 10004:2c57cb7eba5f

(Fpurecopy): Use type test macros.
author Karl Heuer <kwzh@gnu.org>
date Fri, 18 Nov 1994 02:31:20 +0000
parents c5a44b9c6565
children 9424b278cd6a
files src/alloc.c
diffstat 1 files changed, 22 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/alloc.c	Fri Nov 18 02:30:32 1994 +0000
+++ b/src/alloc.c	Fri Nov 18 02:31:20 1994 +0000
@@ -1127,9 +1127,6 @@
   (obj)
      register Lisp_Object obj;
 {
-  register Lisp_Object new, tem;
-  register int i;
-
   if (NILP (Vpurify_flag))
     return obj;
 
@@ -1137,47 +1134,33 @@
       && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
     return obj;
 
-#ifdef SWITCH_ENUM_BUG
-  switch ((int) XTYPE (obj))
-#else
-  switch (XTYPE (obj))
-#endif
-    {
-    case Lisp_Misc:
-      switch (XMISC (obj)->type)
-	{
-	case Lisp_Misc_Marker:
-	  error ("Attempt to copy a marker to pure storage");
-
-	default:
-	  abort ();
-	}
-
-    case Lisp_Cons:
-      return pure_cons (XCONS (obj)->car, XCONS (obj)->cdr);
-
+  if (CONSP (obj))
+    return pure_cons (XCONS (obj)->car, XCONS (obj)->cdr);
 #ifdef LISP_FLOAT_TYPE
-    case Lisp_Float:
-      return make_pure_float (XFLOAT (obj)->data);
+  else if (FLOATP (obj))
+    return make_pure_float (XFLOAT (obj)->data);
 #endif /* LISP_FLOAT_TYPE */
-
-    case Lisp_String:
-      return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size);
+  else if (STRINGP (obj))
+    return make_pure_string (XSTRING (obj)->data, XSTRING (obj)->size);
+  else if (COMPILEDP (obj) || VECTORP (obj))
+    {
+      register struct Lisp_Vector *vec;
+      register int i, size;
 
-    case Lisp_Compiled:
-    case Lisp_Vector:
-      new = make_pure_vector (XVECTOR (obj)->size);
-      for (i = 0; i < XVECTOR (obj)->size; i++)
-	{
-	  tem = XVECTOR (obj)->contents[i];
-	  XVECTOR (new)->contents[i] = Fpurecopy (tem);
-	}
-      XSETTYPE (new, XTYPE (obj));
-      return new;
-
-    default:
+      size = XVECTOR (obj)->size;
+      vec = XVECTOR (make_pure_vector (size));
+      for (i = 0; i < size; i++)
+	vec->contents[i] = Fpurecopy (XVECTOR (obj)->contents[i]);
+      if (COMPILEDP (obj))
+	XSETCOMPILED (obj, vec);
+      else
+	XSETVECTOR (obj, vec);
       return obj;
     }
+  else if (MARKERP (obj))
+    error ("Attempt to copy a marker to pure storage");
+  else
+    return obj;
 }
 
 /* Recording what needs to be marked for gc.  */