From 298670d66573ddb520e03b17bea70e88ed04eaf8 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 14 Dec 2011 19:33:14 +0000 Subject: [PATCH] Inline object functions. [SVN r75939] --- src/engine/object.c | 7 +++++++ src/engine/object.h | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/engine/object.c b/src/engine/object.c index 96e075ee6..399f04ae8 100644 --- a/src/engine/object.c +++ b/src/engine/object.c @@ -29,6 +29,8 @@ #define OBJECT_MAGIC 0xa762e0e3u +#ifndef object_copy + struct hash_header { #ifndef NDEBUG @@ -38,6 +40,8 @@ struct hash_header struct hash_item * next; }; +#endif + struct hash_item { struct hash_header header; @@ -257,6 +261,7 @@ OBJECT * object_new( const char * string ) #endif } +#ifndef object_copy /* * object_copy() - return a copy of an object @@ -330,6 +335,8 @@ unsigned int object_hash( OBJECT * obj ) #endif } +#endif + /* * object_done() - free string tables. */ diff --git a/src/engine/object.h b/src/engine/object.h index 874fa0296..1c123f8b0 100644 --- a/src/engine/object.h +++ b/src/engine/object.h @@ -14,11 +14,30 @@ typedef struct _object OBJECT; OBJECT * object_new ( const char * ); +void object_done ( void ); + +#if defined(NDEBUG) && !defined(BJAM_NO_MEM_CACHE) + +struct hash_header +{ + unsigned int hash; + struct hash_item * next; +}; + +#define object_str( obj ) ( (const char *)( obj ) ) +#define object_copy( obj ) ( obj ) +#define object_free( obj ) ( (void)0 ) +#define object_equal( lhs, rhs ) ( ( lhs ) == ( rhs ) ) +#define object_hash( obj ) ( ((struct hash_header *)( (char *)( obj ) - sizeof(struct hash_header) ))->hash ) + +#else + +const char * object_str ( OBJECT * ); OBJECT * object_copy ( OBJECT * ); void object_free ( OBJECT * ); -const char * object_str ( OBJECT * ); -void object_done ( void ); int object_equal ( OBJECT *, OBJECT * ); unsigned int object_hash ( OBJECT * ); #endif + +#endif