Inlined value_t::_clear(), since it only had one caller.

This commit is contained in:
John Wiegley 2009-02-12 02:35:22 -04:00
parent f8c48d7a6f
commit 9344598eb0

View file

@ -227,30 +227,19 @@ private:
intrusive_ptr<storage_t> storage; intrusive_ptr<storage_t> storage;
/** /**
* _dup() makes a private copy of the current value (if necessary) * Make a private copy of the current value (if necessary) so it can
* so it can subsequently be modified. * subsequently be modified.
*
* _clear() removes our pointer to the current value and initializes
* a new storage bin for things to be stored in.
*/ */
void _dup() { void _dup() {
assert(storage); assert(storage);
if (storage->refc > 1) if (storage->refc > 1)
storage = new storage_t(*storage.get()); storage = new storage_t(*storage.get());
} }
void _clear() {
if (! storage || storage->refc > 1) {
storage = new storage_t;
} else {
storage->data = false; // destruct any other type
storage->type = VOID;
}
}
/** /**
* Because boolean "true" and "false" are so common, a pair of * Because boolean "true" and "false" are so common, a pair of static
* static references are kept to prevent the creation of throwaway * references are kept to prevent the creation of throwaway storage_t
* storage_t objects just to represent these two common values. * objects just to represent these two common values.
*/ */
static intrusive_ptr<storage_t> true_value; static intrusive_ptr<storage_t> true_value;
static intrusive_ptr<storage_t> false_value; static intrusive_ptr<storage_t> false_value;
@ -480,7 +469,10 @@ private:
#endif #endif
assert(is_null()); assert(is_null());
} else { } else {
_clear(); if (! storage || storage->refc > 1)
storage = new storage_t;
else
storage->data = false; // destruct all other types
storage->type = new_type; storage->type = new_type;
assert(is_type(new_type)); assert(is_type(new_type));
} }