From 76dcfcaf833616e20d7363c423a7f73d7c8ac58b Mon Sep 17 00:00:00 2001 From: 8infy <34326714+8infy@users.noreply.github.com> Date: Wed, 8 Apr 2020 12:15:16 +0300 Subject: [PATCH] Removed redundant 'inline' keyword usage. (#159) A function defined entirely inside a class/struct/union definition, whether it's a member function or a non-member friend function, is implicitly an inline function. --- Hazel/src/Hazel/Core/Application.h | 4 ++-- Hazel/src/Hazel/Core/Input.h | 12 ++++++------ Hazel/src/Hazel/Core/Layer.h | 2 +- Hazel/src/Hazel/Core/Log.h | 4 ++-- Hazel/src/Hazel/Events/ApplicationEvent.h | 4 ++-- Hazel/src/Hazel/Events/Event.h | 2 +- Hazel/src/Hazel/Events/KeyEvent.h | 4 ++-- Hazel/src/Hazel/Events/MouseEvent.h | 8 ++++---- Hazel/src/Hazel/Renderer/Buffer.h | 4 ++-- Hazel/src/Hazel/Renderer/RenderCommand.h | 10 +++++----- Hazel/src/Hazel/Renderer/Renderer.h | 2 +- Hazel/src/Hazel/Renderer/RendererAPI.h | 3 +-- Hazel/src/Platform/Windows/WindowsWindow.h | 8 ++++---- 13 files changed, 33 insertions(+), 34 deletions(-) diff --git a/Hazel/src/Hazel/Core/Application.h b/Hazel/src/Hazel/Core/Application.h index ee829d968..13fb03619 100644 --- a/Hazel/src/Hazel/Core/Application.h +++ b/Hazel/src/Hazel/Core/Application.h @@ -26,9 +26,9 @@ namespace Hazel { void PushLayer(Layer* layer); void PushOverlay(Layer* layer); - inline Window& GetWindow() { return *m_Window; } + Window& GetWindow() { return *m_Window; } - inline static Application& Get() { return *s_Instance; } + static Application& Get() { return *s_Instance; } private: void Run(); bool OnWindowClose(WindowCloseEvent& e); diff --git a/Hazel/src/Hazel/Core/Input.h b/Hazel/src/Hazel/Core/Input.h index 9bc680ab3..a5f899986 100644 --- a/Hazel/src/Hazel/Core/Input.h +++ b/Hazel/src/Hazel/Core/Input.h @@ -14,12 +14,12 @@ namespace Hazel { Input(const Input&) = delete; Input& operator=(const Input&) = delete; - inline static bool IsKeyPressed(KeyCode key) { return s_Instance->IsKeyPressedImpl(key); } + static bool IsKeyPressed(KeyCode key) { return s_Instance->IsKeyPressedImpl(key); } - inline static bool IsMouseButtonPressed(MouseCode button) { return s_Instance->IsMouseButtonPressedImpl(button); } - inline static std::pair GetMousePosition() { return s_Instance->GetMousePositionImpl(); } - inline static float GetMouseX() { return s_Instance->GetMouseXImpl(); } - inline static float GetMouseY() { return s_Instance->GetMouseYImpl(); } + static bool IsMouseButtonPressed(MouseCode button) { return s_Instance->IsMouseButtonPressedImpl(button); } + static std::pair GetMousePosition() { return s_Instance->GetMousePositionImpl(); } + static float GetMouseX() { return s_Instance->GetMouseXImpl(); } + static float GetMouseY() { return s_Instance->GetMouseYImpl(); } static Scope Create(); protected: @@ -32,4 +32,4 @@ namespace Hazel { private: static Scope s_Instance; }; -} \ No newline at end of file +} diff --git a/Hazel/src/Hazel/Core/Layer.h b/Hazel/src/Hazel/Core/Layer.h index 566304dc7..3c5e7fac5 100644 --- a/Hazel/src/Hazel/Core/Layer.h +++ b/Hazel/src/Hazel/Core/Layer.h @@ -18,7 +18,7 @@ namespace Hazel { virtual void OnImGuiRender() {} virtual void OnEvent(Event& event) {} - inline const std::string& GetName() const { return m_DebugName; } + const std::string& GetName() const { return m_DebugName; } protected: std::string m_DebugName; }; diff --git a/Hazel/src/Hazel/Core/Log.h b/Hazel/src/Hazel/Core/Log.h index 87ffcb932..c9ac8e0c2 100644 --- a/Hazel/src/Hazel/Core/Log.h +++ b/Hazel/src/Hazel/Core/Log.h @@ -12,8 +12,8 @@ namespace Hazel { public: static void Init(); - inline static Ref& GetCoreLogger() { return s_CoreLogger; } - inline static Ref& GetClientLogger() { return s_ClientLogger; } + static Ref& GetCoreLogger() { return s_CoreLogger; } + static Ref& GetClientLogger() { return s_ClientLogger; } private: static Ref s_CoreLogger; static Ref s_ClientLogger; diff --git a/Hazel/src/Hazel/Events/ApplicationEvent.h b/Hazel/src/Hazel/Events/ApplicationEvent.h index 0f6b1fdb7..275675c1e 100644 --- a/Hazel/src/Hazel/Events/ApplicationEvent.h +++ b/Hazel/src/Hazel/Events/ApplicationEvent.h @@ -10,8 +10,8 @@ namespace Hazel { WindowResizeEvent(unsigned int width, unsigned int height) : m_Width(width), m_Height(height) {} - inline unsigned int GetWidth() const { return m_Width; } - inline unsigned int GetHeight() const { return m_Height; } + unsigned int GetWidth() const { return m_Width; } + unsigned int GetHeight() const { return m_Height; } std::string ToString() const override { diff --git a/Hazel/src/Hazel/Events/Event.h b/Hazel/src/Hazel/Events/Event.h index 7f034c0bd..5a5f9cf11 100644 --- a/Hazel/src/Hazel/Events/Event.h +++ b/Hazel/src/Hazel/Events/Event.h @@ -45,7 +45,7 @@ namespace Hazel { virtual int GetCategoryFlags() const = 0; virtual std::string ToString() const { return GetName(); } - inline bool IsInCategory(EventCategory category) + bool IsInCategory(EventCategory category) { return GetCategoryFlags() & category; } diff --git a/Hazel/src/Hazel/Events/KeyEvent.h b/Hazel/src/Hazel/Events/KeyEvent.h index 2353bcdc4..068950b3c 100644 --- a/Hazel/src/Hazel/Events/KeyEvent.h +++ b/Hazel/src/Hazel/Events/KeyEvent.h @@ -8,7 +8,7 @@ namespace Hazel { class KeyEvent : public Event { public: - inline KeyCode GetKeyCode() const { return m_KeyCode; } + KeyCode GetKeyCode() const { return m_KeyCode; } EVENT_CLASS_CATEGORY(EventCategoryKeyboard | EventCategoryInput) protected: @@ -24,7 +24,7 @@ namespace Hazel { KeyPressedEvent(KeyCode keycode, int repeatCount) : KeyEvent(keycode), m_RepeatCount(repeatCount) {} - inline int GetRepeatCount() const { return m_RepeatCount; } + int GetRepeatCount() const { return m_RepeatCount; } std::string ToString() const override { diff --git a/Hazel/src/Hazel/Events/MouseEvent.h b/Hazel/src/Hazel/Events/MouseEvent.h index a980bd938..020200f3e 100644 --- a/Hazel/src/Hazel/Events/MouseEvent.h +++ b/Hazel/src/Hazel/Events/MouseEvent.h @@ -11,8 +11,8 @@ namespace Hazel { MouseMovedEvent(float x, float y) : m_MouseX(x), m_MouseY(y) {} - inline float GetX() const { return m_MouseX; } - inline float GetY() const { return m_MouseY; } + float GetX() const { return m_MouseX; } + float GetY() const { return m_MouseY; } std::string ToString() const override { @@ -33,8 +33,8 @@ namespace Hazel { MouseScrolledEvent(float xOffset, float yOffset) : m_XOffset(xOffset), m_YOffset(yOffset) {} - inline float GetXOffset() const { return m_XOffset; } - inline float GetYOffset() const { return m_YOffset; } + float GetXOffset() const { return m_XOffset; } + float GetYOffset() const { return m_YOffset; } std::string ToString() const override { diff --git a/Hazel/src/Hazel/Renderer/Buffer.h b/Hazel/src/Hazel/Renderer/Buffer.h index ce74eb91c..2ff8cc775 100644 --- a/Hazel/src/Hazel/Renderer/Buffer.h +++ b/Hazel/src/Hazel/Renderer/Buffer.h @@ -76,8 +76,8 @@ namespace Hazel { CalculateOffsetsAndStride(); } - inline uint32_t GetStride() const { return m_Stride; } - inline const std::vector& GetElements() const { return m_Elements; } + uint32_t GetStride() const { return m_Stride; } + const std::vector& GetElements() const { return m_Elements; } std::vector::iterator begin() { return m_Elements.begin(); } std::vector::iterator end() { return m_Elements.end(); } diff --git a/Hazel/src/Hazel/Renderer/RenderCommand.h b/Hazel/src/Hazel/Renderer/RenderCommand.h index 842fb84f3..e3b88f779 100644 --- a/Hazel/src/Hazel/Renderer/RenderCommand.h +++ b/Hazel/src/Hazel/Renderer/RenderCommand.h @@ -7,27 +7,27 @@ namespace Hazel { class RenderCommand { public: - inline static void Init() + static void Init() { s_RendererAPI->Init(); } - inline static void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) + static void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { s_RendererAPI->SetViewport(x, y, width, height); } - inline static void SetClearColor(const glm::vec4& color) + static void SetClearColor(const glm::vec4& color) { s_RendererAPI->SetClearColor(color); } - inline static void Clear() + static void Clear() { s_RendererAPI->Clear(); } - inline static void DrawIndexed(const Ref& vertexArray, uint32_t count = 0) + static void DrawIndexed(const Ref& vertexArray, uint32_t count = 0) { s_RendererAPI->DrawIndexed(vertexArray, count); } diff --git a/Hazel/src/Hazel/Renderer/Renderer.h b/Hazel/src/Hazel/Renderer/Renderer.h index bfd27fa3c..b359205b9 100644 --- a/Hazel/src/Hazel/Renderer/Renderer.h +++ b/Hazel/src/Hazel/Renderer/Renderer.h @@ -20,7 +20,7 @@ namespace Hazel { static void Submit(const Ref& shader, const Ref& vertexArray, const glm::mat4& transform = glm::mat4(1.0f)); - inline static RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); } + static RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); } private: struct SceneData { diff --git a/Hazel/src/Hazel/Renderer/RendererAPI.h b/Hazel/src/Hazel/Renderer/RendererAPI.h index 34eee078e..2e411d249 100644 --- a/Hazel/src/Hazel/Renderer/RendererAPI.h +++ b/Hazel/src/Hazel/Renderer/RendererAPI.h @@ -21,9 +21,8 @@ namespace Hazel { virtual void DrawIndexed(const Ref& vertexArray, uint32_t indexCount = 0) = 0; - inline static API GetAPI() { return s_API; } + static API GetAPI() { return s_API; } static Scope Create(); - private: static API s_API; }; diff --git a/Hazel/src/Platform/Windows/WindowsWindow.h b/Hazel/src/Platform/Windows/WindowsWindow.h index f4f69714f..cb1d19cb2 100644 --- a/Hazel/src/Platform/Windows/WindowsWindow.h +++ b/Hazel/src/Platform/Windows/WindowsWindow.h @@ -15,15 +15,15 @@ namespace Hazel { void OnUpdate() override; - inline unsigned int GetWidth() const override { return m_Data.Width; } - inline unsigned int GetHeight() const override { return m_Data.Height; } + unsigned int GetWidth() const override { return m_Data.Width; } + unsigned int GetHeight() const override { return m_Data.Height; } // Window attributes - inline void SetEventCallback(const EventCallbackFn& callback) override { m_Data.EventCallback = callback; } + void SetEventCallback(const EventCallbackFn& callback) override { m_Data.EventCallback = callback; } void SetVSync(bool enabled) override; bool IsVSync() const override; - inline virtual void* GetNativeWindow() const { return m_Window; } + virtual void* GetNativeWindow() const { return m_Window; } private: virtual void Init(const WindowProps& props); virtual void Shutdown();