Fabric: Fixes color hash type to prevent bits truncation (#50285)

Summary:
I made a mistake before, it seems we should use std::size_t to prevent bits truncation.

## Changelog:

[IOS] [FIXED] - Fabric: Fixes color hash type to prevent bits truncation

Pull Request resolved: https://github.com/facebook/react-native/pull/50285

Test Plan: N/A

Reviewed By: javache

Differential Revision: D71895413

Pulled By: cipolleschi

fbshipit-source-id: 26cc036bee851902e11abfa8ed5c5c8222421b09
This commit is contained in:
zhongwuzw authored and Facebook GitHub Bot committed 2025-03-26 14:13:19 -07:00
1 parent 0f4e93987e
commit 62536db8c7
2 files changed
+4 -4

No files matched your search

@@ -26,7 +26,7 @@ struct Color {
Color(const ColorComponents& components);
Color() : uiColor_(nullptr){};
int32_t getColor() const;
int32_t getUIColorHash() const;
std::size_t getUIColorHash() const;
static Color createSemanticColor(std::vector<std::string>& semanticItems);
@@ -54,7 +54,7 @@ struct Color {
private:
Color(std::shared_ptr<void> uiColor);
std::shared_ptr<void> uiColor_;
int32_t uiColorHashValue_;
std::size_t uiColorHashValue_;
};
namespace HostPlatformColor {
@@ -132,7 +132,7 @@ UIColor *_Nullable UIColorFromComponentsColor(const facebook::react::ColorCompon
return uiColor;
}
int32_t hashFromUIColor(const std::shared_ptr<void> &uiColor)
std::size_t hashFromUIColor(const std::shared_ptr<void> &uiColor)
{
if (uiColor == nullptr) {
return 0;
@@ -229,7 +229,7 @@ float Color::getChannel(int channelId) const
return static_cast<float>(rgba[channelId]);
}
int32_t Color::getUIColorHash() const
std::size_t Color::getUIColorHash() const
{
return uiColorHashValue_;
}