From 2e88860b321b6c10c971ae19542ae6292cb75ec0 Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Thu, 1 Mar 2018 23:47:42 +0800 Subject: [PATCH] String::getHash rename String::getHashCode --- core/Common/Image.cpp | 6 +++--- core/Common/String.cpp | 2 +- core/Manager/MusicManager.cpp | 4 ++-- core/Node/Node.cpp | 8 ++++---- core/ecommon.h | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/Common/Image.cpp b/core/Common/Image.cpp index 52ba91a5..9330b3ec 100644 --- a/core/Common/Image.cpp +++ b/core/Common/Image.cpp @@ -41,7 +41,7 @@ void e2d::Image::loadFrom(const String & strFilePath) return; } - m_pBitmap = s_mBitmapsFromFile.at(strFilePath.getHash()); + m_pBitmap = s_mBitmapsFromFile.at(strFilePath.getHashCode()); m_fSourceClipX = m_fSourceClipY = 0; m_fSourceClipWidth = m_pBitmap->GetSize().width; m_fSourceClipHeight = m_pBitmap->GetSize().height; @@ -132,7 +132,7 @@ e2d::Point e2d::Image::getClipPos() const bool e2d::Image::preload(const String & fileName) { - if (s_mBitmapsFromFile.find(fileName.getHash()) != s_mBitmapsFromFile.end()) + if (s_mBitmapsFromFile.find(fileName.getHashCode()) != s_mBitmapsFromFile.end()) { return true; } @@ -192,7 +192,7 @@ bool e2d::Image::preload(const String & fileName) // 保存图片指针和图片的 Hash 名 s_mBitmapsFromFile.insert( std::map::value_type( - fileName.getHash(), + fileName.getHashCode(), pBitmap) ); } diff --git a/core/Common/String.cpp b/core/Common/String.cpp index 76d0c8aa..af5c805d 100644 --- a/core/Common/String.cpp +++ b/core/Common/String.cpp @@ -292,7 +292,7 @@ int e2d::String::getLength() const return static_cast(m_str.size()); } -unsigned int e2d::String::getHash() const +unsigned int e2d::String::getHashCode() const { unsigned int hash = 0; diff --git a/core/Manager/MusicManager.cpp b/core/Manager/MusicManager.cpp index 1758e993..797c3bd3 100644 --- a/core/Manager/MusicManager.cpp +++ b/core/Manager/MusicManager.cpp @@ -24,7 +24,7 @@ bool e2d::MusicManager::add(const String & strFilePath) } else { - UINT nRet = strFilePath.getHash(); + UINT nRet = strFilePath.getHashCode(); pPlayer = new Music(); if (pPlayer->_open(strFilePath)) @@ -45,7 +45,7 @@ e2d::Music * e2d::MusicManager::get(const String & strFilePath) if (strFilePath.isEmpty()) return nullptr; - UINT nRet = strFilePath.getHash(); + UINT nRet = strFilePath.getHashCode(); if (getMusicList().end() != getMusicList().find(nRet)) return getMusicList()[nRet]; diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index e8234748..e8d9915b 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -623,7 +623,7 @@ e2d::Node * e2d::Node::getChild(const String & name) { WARN_IF(name.isEmpty(), "Invalid Node name."); - unsigned int hash = name.getHash(); + unsigned int hash = name.getHashCode(); for (auto child : m_vChildren) { @@ -640,7 +640,7 @@ std::vector e2d::Node::getChildren(const String & name) WARN_IF(name.isEmpty(), "Invalid Node name."); - unsigned int hash = name.getHash(); + unsigned int hash = name.getHashCode(); for (auto child : m_vChildren) if (child->m_nHashName == hash && child->m_sName == name) @@ -703,7 +703,7 @@ void e2d::Node::removeChildren(const String & childName) } // 计算名称 Hash 值 - unsigned int hash = childName.getHash(); + unsigned int hash = childName.getHashCode(); size_t size = m_vChildren.size(); for (size_t i = 0; i < size; i++) @@ -860,7 +860,7 @@ void e2d::Node::setName(const String & name) // 保存节点名 m_sName = name; // 保存节点 Hash 名 - m_nHashName = name.getHash(); + m_nHashName = name.getHashCode(); } } diff --git a/core/ecommon.h b/core/ecommon.h index aaffedbd..c7199c69 100644 --- a/core/ecommon.h +++ b/core/ecommon.h @@ -68,7 +68,7 @@ public: int getLength() const; // 获取该字符串的散列值 - unsigned int getHash() const; + unsigned int getHashCode() const; // 后接字符串 String& append(