diff options
author | frosch <frosch@openttd.org> | 2010-01-16 14:17:03 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-01-16 14:17:03 +0000 |
commit | 84ece021fde4850b4755b81bb6886ffced6b7020 (patch) | |
tree | 13e90b3eadadaea5256f90d46826219e2fb98f23 /src | |
parent | e6faf06b687d0d98da2d3bb3a7f294bc701dae38 (diff) | |
download | openttd-84ece021fde4850b4755b81bb6886ffced6b7020.tar.xz |
(svn r18825) -Codechange: Sometimes code is shorter if you do not use a function for deduplication. (skidd13)
Diffstat (limited to 'src')
-rw-r--r-- | src/misc/fixedsizearray.hpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp index fc57c7934..435dfad79 100644 --- a/src/misc/fixedsizearray.hpp +++ b/src/misc/fixedsizearray.hpp @@ -92,16 +92,14 @@ public: FORCEINLINE bool IsFull() const { return Length() >= C; }; /** return true if array is empty */ FORCEINLINE bool IsEmpty() const { return Length() <= 0; }; - /** index validation */ - FORCEINLINE void CheckIdx(uint index) const { assert(index < Length()); } /** add (allocate), but don't construct item */ FORCEINLINE T& Append() { assert(!IsFull()); return data[SizeRef()++]; } /** add and construct item using default constructor */ FORCEINLINE T& AppendC() { T& item = Append(); new(&item)T; return item; } /** return item by index (non-const version) */ - FORCEINLINE T& operator [] (uint index) { CheckIdx(index); return data[index]; } + FORCEINLINE T& operator [] (uint index) { assert(index < Length()); return data[index]; } /** return item by index (const version) */ - FORCEINLINE const T& operator [] (uint index) const { CheckIdx(index); return data[index]; } + FORCEINLINE const T& operator [] (uint index) const { assert(index < Length()); return data[index]; } }; #endif /* FIXEDSIZEARRAY_HPP */ |