diff options
author | smatz <smatz@openttd.org> | 2008-04-06 23:49:45 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-04-06 23:49:45 +0000 |
commit | 76eaed68a07fb0134c99100a0fb49e884b511244 (patch) | |
tree | 86bec7de682cc52c0fc3a81cb21a661c2b0d4a75 /src/oldpool.h | |
parent | bd432258cbbf29a2d37154914aa2361bdc218fbb (diff) | |
download | openttd-76eaed68a07fb0134c99100a0fb49e884b511244.tar.xz |
(svn r12599) -Codechange: force AllocateSafeRaw() to be linked to simplify compiler's decisions about inlining
Diffstat (limited to 'src/oldpool.h')
-rw-r--r-- | src/oldpool.h | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/oldpool.h b/src/oldpool.h index 1bcd41f8c..46d31e999 100644 --- a/src/oldpool.h +++ b/src/oldpool.h @@ -260,32 +260,7 @@ struct PoolItem { } private: - /** - * Allocate a pool item; possibly allocate a new block in the pool. - * @param first the first pool item to start searching - * @pre first <= Tpool->GetSize() - * @return the allocated pool item (or NULL when the pool is full). - */ - static inline T *AllocateSafeRaw(uint &first) - { - uint last_minus_one = Tpool->GetSize() - 1; - - for (T *t = Tpool->Get(first); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) { - if (!t->IsValid()) { - first = t->index; - Tid index = t->index; - - memset(t, 0, Tpool->item_size); - t->index = index; - return t; - } - } - - /* Check if we can add a block to the pool */ - if (Tpool->AddBlockToPool()) return AllocateRaw(first); - - return NULL; - } + static T *AllocateSafeRaw(uint &first); protected: /** @@ -346,7 +321,8 @@ protected: #define DEFINE_OLD_POOL_GENERIC(name, type) \ OldMemoryPool<type> _##name##_pool( \ #name, name##_POOL_MAX_BLOCKS, name##_POOL_BLOCK_SIZE_BITS, sizeof(type), \ - PoolNewBlock<type, &_##name##_pool>, PoolCleanBlock<type, &_##name##_pool>); + PoolNewBlock<type, &_##name##_pool>, PoolCleanBlock<type, &_##name##_pool>); \ + template type *PoolItem<type, type##ID, &_##name##_pool>::AllocateSafeRaw(uint &first); #define STATIC_OLD_POOL(name, type, block_size_bits, max_blocks, new_block_proc, clean_block_proc) \ |