Changeset - r23539:bce8329ee42d
[Not reviewed]
master
0 21 0
Henry Wilson - 5 years ago 2019-03-04 20:49:33
m3henry@googlemail.com
Cleanup: Remove unused size template parameters from SmallMap and Auto[Free|Delete]SmallVector
15 files changed with 20 insertions and 22 deletions:
0 comments (0 inline, 0 general)
src/core/smallmap_type.hpp
Show inline comments
 
@@ -36,13 +36,13 @@ struct SmallPair {
 
 * @tparam T Key type.
 
 * @tparam U Value type.
 
 * @tparam S Unit of allocation.
 
 *
 
 * @see SmallVector
 
 */
 
template <typename T, typename U, uint S = 16>
 
template <typename T, typename U>
 
struct SmallMap : std::vector<SmallPair<T, U> > {
 
	typedef ::SmallPair<T, U> Pair;
 
	typedef Pair *iterator;
 
	typedef const Pair *const_iterator;
 

	
 
	/** Creates new SmallMap. Data are initialized in SmallVector constructor */
src/core/smallvec_type.hpp
Show inline comments
 
@@ -74,15 +74,14 @@ T* grow(std::vector<T>& vec, std::size_t
 
 *
 
 * @note There are no asserts in the class so you have
 
 *       to care about that you grab an item which is
 
 *       inside the list.
 
 *
 
 * @param T The type of the items stored, must be a pointer
 
 * @param S The steps of allocation
 
 */
 
template <typename T, uint S>
 
template <typename T>
 
class AutoFreeSmallVector : public std::vector<T> {
 
public:
 
	~AutoFreeSmallVector()
 
	{
 
		this->Clear();
 
	}
 
@@ -105,15 +104,14 @@ public:
 
 *
 
 * @note There are no asserts in the class so you have
 
 *       to care about that you grab an item which is
 
 *       inside the list.
 
 *
 
 * @param T The type of the items stored, must be a pointer
 
 * @param S The steps of allocation
 
 */
 
template <typename T, uint S>
 
template <typename T>
 
class AutoDeleteSmallVector : public std::vector<T> {
 
public:
 
	~AutoDeleteSmallVector()
 
	{
 
		this->Clear();
 
	}
 
@@ -128,9 +126,9 @@ public:
 
		}
 

	
 
		std::vector<T>::clear();
 
	}
 
};
 

	
 
typedef AutoFreeSmallVector<char*, 4> StringList; ///< Type for a list of strings.
 
typedef AutoFreeSmallVector<char*> StringList; ///< Type for a list of strings.
 

	
 
#endif /* SMALLVEC_TYPE_HPP */
src/game/game_text.hpp
Show inline comments
 
@@ -29,14 +29,14 @@ struct LanguageStrings {
 

	
 
/** Container for all the game strings. */
 
struct GameStrings {
 
	uint version;                  ///< The version of the language strings.
 
	LanguageStrings *cur_language; ///< The current (compiled) language.
 

	
 
	AutoDeleteSmallVector<LanguageStrings *, 4> raw_strings;      ///< The raw strings per language, first must be English/the master language!.
 
	AutoDeleteSmallVector<LanguageStrings *, 4> compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
 
	AutoDeleteSmallVector<LanguageStrings *> raw_strings;      ///< The raw strings per language, first must be English/the master language!.
 
	AutoDeleteSmallVector<LanguageStrings *> compiled_strings; ///< The compiled strings per language, first must be English/the master language!.
 
	StringList string_names;                                      ///< The names of the compiled strings.
 

	
 
	void Compile();
 
};
 

	
 
#endif /* GAME_TEXT_HPP */
src/gfx_layout.cpp
Show inline comments
 
@@ -121,13 +121,13 @@ le_bool Font::getGlyphPoint(LEGlyphID gl
 
	return FALSE;
 
}
 

	
 
/**
 
 * Wrapper for doing layouts with ICU.
 
 */
 
class ICUParagraphLayout : public AutoDeleteSmallVector<ParagraphLayouter::Line *, 4>, public ParagraphLayouter {
 
class ICUParagraphLayout : public AutoDeleteSmallVector<ParagraphLayouter::Line *>, public ParagraphLayouter {
 
	icu::ParagraphLayout *p; ///< The actual ICU paragraph layout.
 
public:
 
	/** Visual run contains data about the bit of text with the same font. */
 
	class ICUVisualRun : public ParagraphLayouter::VisualRun {
 
		const icu::ParagraphLayout::VisualRun *vr; ///< The actual ICU vr.
 

	
 
@@ -140,13 +140,13 @@ public:
 
		const float *GetPositions() const    { return vr->getPositions(); }
 
		int GetLeading() const               { return vr->getLeading(); }
 
		const int *GetGlyphToCharMap() const { return vr->getGlyphToCharMap(); }
 
	};
 

	
 
	/** A single line worth of VisualRuns. */
 
	class ICULine : public AutoDeleteSmallVector<ICUVisualRun *, 4>, public ParagraphLayouter::Line {
 
	class ICULine : public AutoDeleteSmallVector<ICUVisualRun *>, public ParagraphLayouter::Line {
 
		icu::ParagraphLayout::Line *l; ///< The actual ICU line.
 

	
 
	public:
 
		ICULine(icu::ParagraphLayout::Line *l) : l(l)
 
		{
 
			for (int i = 0; i < l->countRuns(); i++) {
 
@@ -266,13 +266,13 @@ public:
 
		const float *GetPositions() const;
 
		int GetLeading() const;
 
		const int *GetGlyphToCharMap() const;
 
	};
 

	
 
	/** A single line worth of VisualRuns. */
 
	class FallbackLine : public AutoDeleteSmallVector<FallbackVisualRun *, 4>, public ParagraphLayouter::Line {
 
	class FallbackLine : public AutoDeleteSmallVector<FallbackVisualRun *>, public ParagraphLayouter::Line {
 
	public:
 
		int GetLeading() const;
 
		int GetWidth() const;
 
		int CountRuns() const;
 
		const ParagraphLayouter::VisualRun *GetVisualRun(int run) const;
 

	
src/gfx_layout.h
Show inline comments
 
@@ -147,13 +147,13 @@ public:
 

	
 
/**
 
 * The layouter performs all the layout work.
 
 *
 
 * It also accounts for the memory allocations and frees.
 
 */
 
class Layouter : public AutoDeleteSmallVector<const ParagraphLayouter::Line *, 4> {
 
class Layouter : public AutoDeleteSmallVector<const ParagraphLayouter::Line *> {
 
	const char *string; ///< Pointer to the original string.
 

	
 
	/** Key into the linecache */
 
	struct LineCacheKey {
 
		FontState state_before;  ///< Font state at the beginning of the line.
 
		std::string str;         ///< Source string of the line (including colour and font size codes).
src/network/core/address.h
Show inline comments
 
@@ -16,13 +16,13 @@
 
#include "config.h"
 
#include "../../string_func.h"
 
#include "../../core/smallmap_type.hpp"
 

	
 
class NetworkAddress;
 
typedef std::vector<NetworkAddress> NetworkAddressList; ///< Type for a list of addresses.
 
typedef SmallMap<NetworkAddress, SOCKET, 4> SocketList;    ///< Type for a mapping between address and socket.
 
typedef SmallMap<NetworkAddress, SOCKET> SocketList;    ///< Type for a mapping between address and socket.
 

	
 
/**
 
 * Wrapper for (un)resolved network addresses; there's no reason to transform
 
 * a numeric IP to a string and then back again to pass it to functions. It
 
 * furthermore allows easier delaying of the hostname lookup.
 
 */
src/network/network_client.cpp
Show inline comments
 
@@ -38,13 +38,13 @@
 

	
 

	
 
/** Read some packets, and when do use that data as initial load filter. */
 
struct PacketReader : LoadFilter {
 
	static const size_t CHUNK = 32 * 1024;  ///< 32 KiB chunks of memory.
 

	
 
	AutoFreeSmallVector<byte *, 16> blocks; ///< Buffer with blocks of allocated memory.
 
	AutoFreeSmallVector<byte *> blocks;     ///< Buffer with blocks of allocated memory.
 
	byte *buf;                              ///< Buffer we're going to write to/read from.
 
	byte *bufe;                             ///< End of the buffer we write to/read from.
 
	byte **block;                           ///< The block we're reading from/writing to.
 
	size_t written_bytes;                   ///< The total number of bytes we've written.
 
	size_t read_bytes;                      ///< The total number of read bytes.
 

	
src/newgrf_config.h
Show inline comments
 
@@ -130,13 +130,13 @@ struct GRFParameterInfo {
 
	uint32 min_value;      ///< The minimal value this parameter can have
 
	uint32 max_value;      ///< The maximal value of this parameter
 
	uint32 def_value;      ///< Default value of this parameter
 
	byte param_nr;         ///< GRF parameter to store content in
 
	byte first_bit;        ///< First bit to use in the GRF parameter
 
	byte num_bit;          ///< Number of bits to use for this parameter
 
	SmallMap<uint32, struct GRFText *, 8> value_names; ///< Names for each value.
 
	SmallMap<uint32, struct GRFText *> value_names; ///< Names for each value.
 
	bool complete_labels;  ///< True if all values have a label.
 

	
 
	uint32 GetValue(struct GRFConfig *config) const;
 
	void SetValue(struct GRFConfig *config, uint32 value);
 
	void Finalize();
 
};
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -62,13 +62,13 @@ public:
 
		virtual int GetLeading() const { return this->font->fc->GetHeight(); }
 
		virtual int GetGlyphCount() const { return (int)this->glyphs.size(); }
 
		int GetAdvance() const { return this->total_advance; }
 
	};
 

	
 
	/** A single line worth of VisualRuns. */
 
	class CoreTextLine : public AutoDeleteSmallVector<CoreTextVisualRun *, 4>, public ParagraphLayouter::Line {
 
	class CoreTextLine : public AutoDeleteSmallVector<CoreTextVisualRun *>, public ParagraphLayouter::Line {
 
	public:
 
		CoreTextLine(CTLineRef line, const FontMap &fontMapping, const CoreTextParagraphLayoutFactory::CharType *buff)
 
		{
 
			CFArrayRef runs = CTLineGetGlyphRuns(line);
 
			for (CFIndex i = 0; i < CFArrayGetCount(runs); i++) {
 
				CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, i);
src/os/windows/string_uniscribe.cpp
Show inline comments
 
@@ -103,13 +103,13 @@ public:
 
		virtual int GetLeading() const { return this->font->fc->GetHeight(); }
 
		virtual int GetGlyphCount() const { return this->num_glyphs; }
 
		int GetAdvance() const { return this->total_advance; }
 
	};
 

	
 
	/** A single line worth of VisualRuns. */
 
	class UniscribeLine : public AutoDeleteSmallVector<UniscribeVisualRun *, 4>, public ParagraphLayouter::Line {
 
	class UniscribeLine : public AutoDeleteSmallVector<UniscribeVisualRun *>, public ParagraphLayouter::Line {
 
	public:
 
		virtual int GetLeading() const;
 
		virtual int GetWidth() const;
 
		virtual int CountRuns() const { return this->size();  }
 
		virtual const VisualRun *GetVisualRun(int run) const { return this->at(run);  }
 

	
src/saveload/saveload.cpp
Show inline comments
 
@@ -122,13 +122,13 @@ struct ReadBuffer {
 
	}
 
};
 

	
 

	
 
/** Container for dumping the savegame (quickly) to memory. */
 
struct MemoryDumper {
 
	AutoFreeSmallVector<byte *, 16> blocks; ///< Buffer with blocks of allocated memory.
 
	AutoFreeSmallVector<byte *> blocks; ///< Buffer with blocks of allocated memory.
 
	byte *buf;                              ///< Buffer we're going to write to.
 
	byte *bufe;                             ///< End of the buffer we write to.
 

	
 
	/** Initialise our variables. */
 
	MemoryDumper() : buf(NULL), bufe(NULL)
 
	{
src/settings_func.h
Show inline comments
 
@@ -27,13 +27,13 @@ void SaveToConfig();
 

	
 
void IniLoadWindowSettings(IniFile *ini, const char *grpname, void *desc);
 
void IniSaveWindowSettings(IniFile *ini, const char *grpname, void *desc);
 

	
 
/* Functions to load and save NewGRF settings to a separate
 
 * configuration file, used for presets. */
 
typedef AutoFreeSmallVector<char *, 4> GRFPresetList;
 
typedef AutoFreeSmallVector<char *> GRFPresetList;
 

	
 
void GetGRFPresetList(GRFPresetList *list);
 
struct GRFConfig *LoadGRFPresetFromConfig(const char *config_name);
 
void SaveGRFPresetToConfig(const char *config_name, struct GRFConfig *config);
 
void DeleteGRFPresetFromConfig(const char *config_name);
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -3454,13 +3454,13 @@ Town *ClosestTownFromTile(TileIndex tile
 
		default:
 
			return CalcClosestTownFromTile(tile, threshold);
 
	}
 
}
 

	
 
static bool _town_rating_test = false; ///< If \c true, town rating is in test-mode.
 
static SmallMap<const Town *, int, 4> _town_test_ratings; ///< Map of towns to modified ratings, while in town rating test-mode.
 
static SmallMap<const Town *, int> _town_test_ratings; ///< Map of towns to modified ratings, while in town rating test-mode.
 

	
 
/**
 
 * Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings.
 
 * The function is safe to use in nested calls.
 
 * @param mode Test mode switch (\c true means go to test-mode, \c false means leave test-mode).
 
 */
src/vehicle.cpp
Show inline comments
 
@@ -685,13 +685,13 @@ void ResetVehicleColourMap()
 
}
 

	
 
/**
 
 * List of vehicles that should check for autoreplace this tick.
 
 * Mapping of vehicle -> leave depot immediately after autoreplace.
 
 */
 
typedef SmallMap<Vehicle *, bool, 4> AutoreplaceMap;
 
typedef SmallMap<Vehicle *, bool> AutoreplaceMap;
 
static AutoreplaceMap _vehicles_to_autoreplace;
 

	
 
void InitializeVehicles()
 
{
 
	_vehicles_to_autoreplace.clear();
 
	_vehicles_to_autoreplace.shrink_to_fit();
src/widgets/dropdown_type.h
Show inline comments
 
@@ -95,13 +95,13 @@ public:
 
	void SetDimension(Dimension d);
 
};
 

	
 
/**
 
 * A drop down list is a collection of drop down list items.
 
 */
 
typedef AutoDeleteSmallVector<const DropDownListItem *, 4> DropDownList;
 
typedef AutoDeleteSmallVector<const DropDownListItem *> DropDownList;
 

	
 
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false);
 

	
 
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false);
 

	
 
#endif /* WIDGETS_DROPDOWN_TYPE_H */
0 comments (0 inline, 0 general)