Changeset - r14426:0aaa0726efa5
[Not reviewed]
master
0 2 0
rubidium - 15 years ago 2010-02-03 17:25:56
rubidium@openttd.org
(svn r18993) -Codechange: allow allocating multiple items in a SmallVector with one call.
2 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/core/smallvec_type.hpp
Show inline comments
 
@@ -76,16 +76,20 @@ public:
 

	
 
	/**
 
	 * Append an item and return it.
 
	 * @param to_add the number of items to append
 
	 * @return pointer to newly allocated item
 
	 */
 
	FORCEINLINE T *Append()
 
	FORCEINLINE T *Append(size_t to_add = 1)
 
	{
 
		if (this->items == this->capacity) {
 
			this->capacity += S;
 
		size_t begin = this->items;
 
		this->items += to_add;
 

	
 
		if (this->items > this->capacity) {
 
			this->capacity = Align(this->items, S);
 
			this->data = ReallocT(this->data, this->capacity);
 
		}
 

	
 
		return &this->data[this->items++];
 
		return &this->data[begin];
 
	}
 

	
 
	/**
src/newgrf_sound.cpp
Show inline comments
 
@@ -18,7 +18,7 @@
 
#include "sound_func.h"
 
#include "core/mem_func.hpp"
 

	
 
static SmallVector<SoundEntry, ORIGINAL_SAMPLE_COUNT> _sounds;
 
static SmallVector<SoundEntry, 8> _sounds;
 

	
 

	
 
/* Allocate a new Sound */
0 comments (0 inline, 0 general)