Specify the length of hash string if possible 90/322290/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 7 Apr 2025 09:01:55 +0000 (18:01 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Wed, 9 Apr 2025 06:14:08 +0000 (06:14 +0000)
Let we specify the length of hash calculation buffer size if possible

Change-Id: I5f7206e0c184c0449dd1a8f430c5e3ad50f1a932
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-scene3d/internal/common/image-resource-loader.cpp
dali-toolkit/internal/visuals/npatch/npatch-loader.cpp
dali-toolkit/internal/visuals/visual-url.cpp
dali-toolkit/internal/visuals/visual-url.h

index a93005464191ed13c13b27e8f07987186a7b9098..303afd0a956571c151d35ba45a1bb3c7fe17a652 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -131,7 +131,7 @@ std::size_t GenerateHash(const ImageInformation& info)
     *hashTargetPtr = (info.mSamplingMode);
   }
 
-  return Dali::CalculateHash(info.mUrl) ^ Dali::CalculateHash(hashTarget);
+  return Dali::CalculateHash(std::string_view(info.mUrl.data(), info.mUrl.size())) ^ Dali::CalculateHash(hashTarget);
 }
 
 std::size_t GenerateHash(const Dali::PixelData& pixelData, bool mipmapRequired)
index a02fe69ca7bd97c0b5caa1039662b756bd41b054..242b54cb70ea56a82d6b41092ffa061c956dcfd4 100644 (file)
@@ -22,7 +22,6 @@
 #include <dali-toolkit/internal/visuals/rendering-addon.h>
 
 // EXTERNAL HEADERS
-#include <dali/devel-api/common/hash.h>
 #include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/trace.h>
@@ -202,7 +201,7 @@ void NPatchLoader::Process(bool postProcessor)
 
 NPatchDataPtr NPatchLoader::GetNPatchData(const VisualUrl& url, const Rect<int>& border, bool& preMultiplyOnLoad)
 {
-  std::size_t                              hash  = CalculateHash(url.GetUrl());
+  std::size_t                              hash  = url.GetUrlHash();
   std::vector<NPatchInfo>::size_type       index = UNINITIALIZED_ID;
   const std::vector<NPatchInfo>::size_type count = mCache.size();
 
index 2528ca54e500189542ee36ed7acc12bff399f588..9662e4be591f0015cc6fd3d33e9b9accc46c4214 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -311,9 +311,9 @@ std::string VisualUrl::GetEllipsedUrl() const
   return mUrl;
 }
 
-std::uint64_t VisualUrl::GetUrlHash() const
+std::size_t VisualUrl::GetUrlHash() const
 {
-  return DALI_UNLIKELY(mUrlHash == 0) ? (mUrlHash = Dali::CalculateHash(mUrl)) : mUrlHash;
+  return DALI_UNLIKELY(mUrlHash == 0) ? (mUrlHash = Dali::CalculateHash(std::string_view(mUrl.data(), mUrl.size()))) : mUrlHash;
 }
 
 VisualUrl::Type VisualUrl::GetType() const
index 41ccb27b4ea24b39d00abb5fcf25e4a18f112618..da398b7643b856af055d27b66854958b5ad0cb24 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
 
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -116,7 +116,7 @@ public:
    * Get the hash value of full URL
    * @return The hash value of url
    */
-  std::uint64_t GetUrlHash() const;
+  std::size_t GetUrlHash() const;
 
   /**
    * Get the visual type of the URL
@@ -225,7 +225,7 @@ private:
   Type         mType;
   ProtocolType mLocation;
 
-  mutable std::uint64_t mUrlHash;
+  mutable std::size_t mUrlHash;
 };
 
 } // namespace Internal