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 | |
parent | bd432258cbbf29a2d37154914aa2361bdc218fbb (diff) | |
download | openttd-76eaed68a07fb0134c99100a0fb49e884b511244.tar.xz |
(svn r12599) -Codechange: force AllocateSafeRaw() to be linked to simplify compiler's decisions about inlining
-rw-r--r-- | projects/openttd_vs80.vcproj | 4 | ||||
-rw-r--r-- | projects/openttd_vs90.vcproj | 4 | ||||
-rw-r--r-- | source.list | 1 | ||||
-rw-r--r-- | src/cargopacket.cpp | 1 | ||||
-rw-r--r-- | src/depot.cpp | 1 | ||||
-rw-r--r-- | src/engine.cpp | 1 | ||||
-rw-r--r-- | src/group_cmd.cpp | 1 | ||||
-rw-r--r-- | src/industry_cmd.cpp | 1 | ||||
-rw-r--r-- | src/oldpool.h | 30 | ||||
-rw-r--r-- | src/oldpool_func.h | 34 | ||||
-rw-r--r-- | src/order_cmd.cpp | 1 | ||||
-rw-r--r-- | src/signs.cpp | 1 | ||||
-rw-r--r-- | src/station_cmd.cpp | 1 | ||||
-rw-r--r-- | src/town_cmd.cpp | 1 | ||||
-rw-r--r-- | src/vehicle.cpp | 1 | ||||
-rw-r--r-- | src/waypoint.cpp | 1 |
16 files changed, 57 insertions, 27 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj index ec5bb6673..3507106ea 100644 --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -1188,6 +1188,10 @@ > </File> <File + RelativePath=".\..\src\oldpool_func.h" + > + </File> + <File RelativePath=".\..\src\openttd.h" > </File> diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj index df74b8624..e4be42d9c 100644 --- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -1185,6 +1185,10 @@ > </File> <File + RelativePath=".\..\src\oldpool_func.h" + > + </File> + <File RelativePath=".\..\src\openttd.h" > </File> diff --git a/source.list b/source.list index fdde4965e..f08c4302d 100644 --- a/source.list +++ b/source.list @@ -205,6 +205,7 @@ music/null_m.h sound/null_s.h video/null_v.h oldpool.h +oldpool_func.h openttd.h order_base.h order_func.h diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index 9d5f14b04..d4c8d0871 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -7,6 +7,7 @@ #include "station_base.h" #include "cargopacket.h" #include "saveload.h" +#include "oldpool_func.h" /* Initialize the cargopacket-pool */ DEFINE_OLD_POOL_GENERIC(CargoPacket, CargoPacket) diff --git a/src/depot.cpp b/src/depot.cpp index 2ee984e38..c842aba1d 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -9,6 +9,7 @@ #include "saveload.h" #include "order_func.h" #include "window_func.h" +#include "oldpool_func.h" #include "table/strings.h" diff --git a/src/engine.cpp b/src/engine.cpp index 01b1fec47..71d56d5cb 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -25,6 +25,7 @@ #include "autoreplace_gui.h" #include "string_func.h" #include "settings_type.h" +#include "oldpool_func.h" #include "table/strings.h" #include "table/engines.h" diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 7d708161e..52f612cc0 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -22,6 +22,7 @@ #include "string_func.h" #include "player_func.h" #include "order_func.h" +#include "oldpool_func.h" #include "table/strings.h" diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 568ea1918..510aa2219 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -37,6 +37,7 @@ #include "vehicle_func.h" #include "sound_func.h" #include "station_base.h" +#include "oldpool_func.h" #include "table/strings.h" #include "table/sprites.h" 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) \ diff --git a/src/oldpool_func.h b/src/oldpool_func.h new file mode 100644 index 000000000..e4d1c47d5 --- /dev/null +++ b/src/oldpool_func.h @@ -0,0 +1,34 @@ +/* $Id$ */ + +#ifndef OLDPOOL_FUNC_H + +#include "oldpool.h" + +/** + * 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). + */ +template<typename T, typename Tid, OldMemoryPool<T> *Tpool> T *PoolItem<T, Tid, Tpool>::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; +} + +#endif /* OLDPOOL_FUNC_H */ diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index a864d554d..ef12ecf02 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -25,6 +25,7 @@ #include "newgrf_cargo.h" #include "timetable.h" #include "vehicle_func.h" +#include "oldpool_func.h" #include "table/strings.h" diff --git a/src/signs.cpp b/src/signs.cpp index 4b3146b22..a1dce3304 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -19,6 +19,7 @@ #include "window_func.h" #include "map_func.h" #include "string_func.h" +#include "oldpool_func.h" #include "table/strings.h" diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 555689149..30ef4a99d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -42,6 +42,7 @@ #include "vehicle_func.h" #include "string_func.h" #include "signal_func.h" +#include "oldpool_func.h" #include "table/sprites.h" #include "table/strings.h" diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index eda83df20..70295f596 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -40,6 +40,7 @@ #include "window_func.h" #include "string_func.h" #include "newgrf_cargo.h" +#include "oldpool_func.h" #include "table/strings.h" #include "table/sprites.h" diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c874c1aa5..03bd7113b 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -46,6 +46,7 @@ #include "autoreplace_gui.h" #include "string_func.h" #include "settings_type.h" +#include "oldpool_func.h" #include "table/sprites.h" #include "table/strings.h" diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 5d2db9c5a..b53466559 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -32,6 +32,7 @@ #include "player_func.h" #include "settings_type.h" #include "newgrf_station.h" +#include "oldpool_func.h" #include "table/strings.h" |