Change most associative containers to their respective 'unordered' version

This commit is contained in:
Vittorio Romeo 2021-12-06 11:36:16 +00:00
parent 93410afdc7
commit 51ebeaf383
14 changed files with 52 additions and 50 deletions

View File

@ -7,7 +7,7 @@
#include <sstream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
namespace
@ -18,7 +18,7 @@ namespace
sf::Text value;
};
typedef std::map<std::string, JoystickObject> Texts;
typedef std::unordered_map<std::string, JoystickObject> Texts;
Texts texts;
std::ostringstream sstr;
float threshold = 0.1f;

View File

@ -33,7 +33,7 @@
#include <SFML/System/Time.hpp>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
namespace sf
@ -267,7 +267,7 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::set<Sound*> SoundList; //!< Set of unique sound instances
typedef std::unordered_set<Sound*> SoundList; //!< Set of unique sound instances
////////////////////////////////////////////////////////////
// Member data

View File

@ -32,7 +32,7 @@
#include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Rect.hpp>
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
@ -327,7 +327,7 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<Uint64, Glyph> GlyphTable; //!< Table mapping a codepoint to its glyph
typedef std::unordered_map<Uint64, Glyph> GlyphTable; //!< Table mapping a codepoint to its glyph
////////////////////////////////////////////////////////////
/// \brief Structure defining a page of glyphs
@ -387,7 +387,7 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<unsigned int, Page> PageTable; //!< Table mapping a character size to its page (texture)
typedef std::unordered_map<unsigned int, Page> PageTable; //!< Table mapping a character size to its page (texture)
////////////////////////////////////////////////////////////
// Member data

View File

@ -34,8 +34,8 @@
#include <SFML/System/NonCopyable.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/System/Vector3.hpp>
#include <map>
#include <string>
#include <unordered_map>
namespace sf
@ -739,8 +739,8 @@ private:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<int, const Texture*> TextureTable;
typedef std::map<std::string, int> UniformTable;
typedef std::unordered_map<int, const Texture*> TextureTable;
typedef std::unordered_map<std::string, int> UniformTable;
////////////////////////////////////////////////////////////
// Member data

View File

@ -173,7 +173,7 @@ public:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<std::string, std::string> FieldTable;
typedef std::map<std::string, std::string> FieldTable; // Use an ordered map for predictable payloads
////////////////////////////////////////////////////////////
// Member data
@ -333,7 +333,7 @@ public:
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<std::string, std::string> FieldTable;
typedef std::map<std::string, std::string> FieldTable; // Use an ordered map for predictable payloads
////////////////////////////////////////////////////////////
// Member data

View File

@ -39,7 +39,7 @@
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <unordered_map>
// GL_QUADS is unavailable on OpenGL ES, thus we need to define GL_QUADS ourselves
@ -71,7 +71,7 @@ namespace
// Map to help us detect whether a different RenderTarget
// has been activated within a single context
typedef std::map<sf::Uint64, sf::Uint64> ContextRenderTargetMap;
typedef std::unordered_map<sf::Uint64, sf::Uint64> ContextRenderTargetMap;
ContextRenderTargetMap contextRenderTargetMap;
// Check if a RenderTarget with the given ID is active in the current context

View File

@ -32,6 +32,8 @@
#include <SFML/System/Lock.hpp>
#include <SFML/System/Err.hpp>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <set>
@ -40,7 +42,7 @@ namespace
// Set to track all active FBO mappings
// This is used to free active FBOs while their owning
// RenderTextureImplFBO is still alive
std::set<std::map<sf::Uint64, unsigned int>*> frameBuffers;
std::unordered_set<std::unordered_map<sf::Uint64, unsigned int>*> frameBuffers;
// Set to track all stale FBOs
// This is used to free stale FBOs after their owning
@ -84,9 +86,9 @@ namespace
sf::Uint64 contextId = sf::Context::getActiveContextId();
// Destroy active frame buffer objects
for (std::set<std::map<sf::Uint64, unsigned int>*>::iterator frameBuffersIter = frameBuffers.begin(); frameBuffersIter != frameBuffers.end(); ++frameBuffersIter)
for (std::unordered_set<std::unordered_map<sf::Uint64, unsigned int>*>::iterator frameBuffersIter = frameBuffers.begin(); frameBuffersIter != frameBuffers.end(); ++frameBuffersIter)
{
for (std::map<sf::Uint64, unsigned int>::iterator iter = (*frameBuffersIter)->begin(); iter != (*frameBuffersIter)->end(); ++iter)
for (std::unordered_map<sf::Uint64, unsigned int>::iterator iter = (*frameBuffersIter)->begin(); iter != (*frameBuffersIter)->end(); ++iter)
{
if (iter->first == contextId)
{
@ -160,10 +162,10 @@ RenderTextureImplFBO::~RenderTextureImplFBO()
}
// Move all frame buffer objects to stale set
for (std::map<Uint64, unsigned int>::iterator iter = m_frameBuffers.begin(); iter != m_frameBuffers.end(); ++iter)
for (std::unordered_map<Uint64, unsigned int>::iterator iter = m_frameBuffers.begin(); iter != m_frameBuffers.end(); ++iter)
staleFrameBuffers.emplace(iter->first, iter->second);
for (std::map<Uint64, unsigned int>::iterator iter = m_multisampleFrameBuffers.begin(); iter != m_multisampleFrameBuffers.end(); ++iter)
for (std::unordered_map<Uint64, unsigned int>::iterator iter = m_multisampleFrameBuffers.begin(); iter != m_multisampleFrameBuffers.end(); ++iter)
staleFrameBuffers.emplace(iter->first, iter->second);
// Clean up FBOs
@ -540,7 +542,7 @@ bool RenderTextureImplFBO::activate(bool active)
{
Lock lock(mutex);
std::map<Uint64, unsigned int>::iterator iter;
std::unordered_map<Uint64, unsigned int>::iterator iter;
if (m_multisample)
{
@ -594,8 +596,8 @@ void RenderTextureImplFBO::updateTexture(unsigned int)
Lock lock(mutex);
std::map<Uint64, unsigned int>::iterator iter = m_frameBuffers.find(contextId);
std::map<Uint64, unsigned int>::iterator multisampleIter = m_multisampleFrameBuffers.find(contextId);
std::unordered_map<Uint64, unsigned int>::iterator iter = m_frameBuffers.find(contextId);
std::unordered_map<Uint64, unsigned int>::iterator multisampleIter = m_multisampleFrameBuffers.find(contextId);
if ((iter != m_frameBuffers.end()) && (multisampleIter != m_multisampleFrameBuffers.end()))
{

View File

@ -31,7 +31,7 @@
#include <SFML/Graphics/RenderTextureImpl.hpp>
#include <SFML/Window/Context.hpp>
#include <SFML/Window/GlResource.hpp>
#include <map>
#include <unordered_map>
namespace sf
@ -136,17 +136,17 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::map<Uint64, unsigned int> m_frameBuffers; //!< OpenGL frame buffer objects per context
std::map<Uint64, unsigned int> m_multisampleFrameBuffers; //!< Optional per-context OpenGL frame buffer objects with multisample attachments
unsigned int m_depthStencilBuffer; //!< Optional depth/stencil buffer attached to the frame buffer
unsigned int m_colorBuffer; //!< Optional multisample color buffer attached to the frame buffer
unsigned int m_width; //!< Width of the attachments
unsigned int m_height; //!< Height of the attachments
Context* m_context; //!< Backup OpenGL context, used when none already exist
unsigned int m_textureId; //!< The ID of the texture to attach to the FBO
bool m_multisample; //!< Whether we have to create a multisample frame buffer as well
bool m_stencil; //!< Whether we have stencil attachment
bool m_sRgb; //!< Whether we need to encode drawn pixels into sRGB color space
std::unordered_map<Uint64, unsigned int> m_frameBuffers; //!< OpenGL frame buffer objects per context
std::unordered_map<Uint64, unsigned int> m_multisampleFrameBuffers; //!< Optional per-context OpenGL frame buffer objects with multisample attachments
unsigned int m_depthStencilBuffer; //!< Optional depth/stencil buffer attached to the frame buffer
unsigned int m_colorBuffer; //!< Optional multisample color buffer attached to the frame buffer
unsigned int m_width; //!< Width of the attachments
unsigned int m_height; //!< Height of the attachments
Context* m_context; //!< Backup OpenGL context, used when none already exist
unsigned int m_textureId; //!< The ID of the texture to attach to the FBO
bool m_multisample; //!< Whether we have to create a multisample frame buffer as well
bool m_stencil; //!< Whether we have stencil attachment
bool m_sRgb; //!< Whether we need to encode drawn pixels into sRGB color space
};
} // namespace priv

View File

@ -34,7 +34,7 @@
#include <android/native_activity.h>
#include <android/configuration.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <fstream>
@ -73,7 +73,7 @@ struct ActivityStates
void (*forwardEvent)(const Event& event);
int (*processEvent)(int fd, int events, void* data);
std::map<int, Vector2i> touchEvents;
std::unordered_map<int, Vector2i> touchEvents;
Vector2i mousePosition;
bool isButtonPressed[Mouse::ButtonCount];

View File

@ -32,7 +32,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
@ -49,8 +49,8 @@
namespace
{
std::map<unsigned int, std::string> plugged;
std::map<int, std::pair<int, int> > hatValueMap;
std::unordered_map<unsigned int, std::string> plugged;
std::unordered_map<int, std::pair<int, int> > hatValueMap;
bool isJoystick(const char *name)
{

View File

@ -36,7 +36,7 @@
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <unordered_map>
#include <utility>
#include <cstdlib>
#include <cstring>
@ -176,7 +176,7 @@ namespace
// context is going to be destroyed
// Unshareable OpenGL resources rely on this to clean up properly
// whenever a context containing them is destroyed
typedef std::set<std::pair<sf::ContextDestroyCallback, void*> > ContextDestroyCallbacks;
typedef std::unordered_map<sf::ContextDestroyCallback, void*> ContextDestroyCallbacks;
ContextDestroyCallbacks contextDestroyCallbacks;
// This structure contains all the state necessary to

View File

@ -32,7 +32,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
@ -44,8 +44,8 @@
namespace
{
std::map<unsigned int, std::string> plugged;
std::map<int, std::pair<int, int> > hatValueMap;
std::unordered_map<unsigned int, std::string> plugged;
std::unordered_map<int, std::pair<int, int> > hatValueMap;
bool isJoystick(const char *name)
{

View File

@ -34,7 +34,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/hid/IOHIDDevice.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <map>
#include <unordered_map>
#include <vector>
namespace sf
@ -116,9 +116,9 @@ private:
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
typedef long Location;
typedef std::map<sf::Joystick::Axis, IOHIDElementRef> AxisMap;
typedef std::vector<IOHIDElementRef> ButtonsVector;
typedef long Location;
typedef std::unordered_map<sf::Joystick::Axis, IOHIDElementRef> AxisMap;
typedef std::vector<IOHIDElementRef> ButtonsVector;
AxisMap m_axis; ///< Axes (but not POV/Hat) of the joystick
IOHIDElementRef m_hat; ///< POV/Hat axis of the joystick

View File

@ -32,7 +32,7 @@
#include <X11/keysym.h>
#include <cassert>
#include <cstdlib>
#include <map>
#include <unordered_map>
namespace
@ -42,7 +42,7 @@ namespace
unsigned int referenceCount = 0;
sf::Mutex mutex;
typedef std::map<std::string, Atom> AtomMap;
typedef std::unordered_map<std::string, Atom> AtomMap;
AtomMap atoms;
}