Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sour-icons-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"posthog-server": patch
---

Remove redundant equals/hashCode from FeatureFlag-related data classes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,4 @@ internal data class FeatureFlagCacheEntry(
fun isExpired(currentTime: Long = System.currentTimeMillis()): Boolean {
return currentTime >= expiresAt
}

override fun hashCode(): Int {
var result = flags?.hashCode() ?: 0
result = 31 * result + (timestamp xor (timestamp ushr 32)).toInt()
result = 31 * result + (expiresAt xor (expiresAt ushr 32)).toInt()
result = 31 * result + (requestId?.hashCode() ?: 0)
result = 31 * result + (evaluatedAt?.hashCode() ?: 0)
result = 31 * result + (error?.hashCode() ?: 0)
return result
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is FeatureFlagCacheEntry) return false

if (flags != other.flags) return false
if (timestamp != other.timestamp) return false
if (expiresAt != other.expiresAt) return false
if (requestId != other.requestId) return false
if (evaluatedAt != other.evaluatedAt) return false
if (error != other.error) return false

return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,4 @@ internal data class FeatureFlagCacheKey(
val groups: Map<String, String>?,
val personProperties: Map<String, Any?>?,
val groupProperties: Map<String, Map<String, Any?>>?,
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is FeatureFlagCacheKey) return false

if (distinctId != other.distinctId) return false
if (groups != other.groups) return false
if (personProperties != other.personProperties) return false
if (groupProperties != other.groupProperties) return false

return true
}

override fun hashCode(): Int {
var result = distinctId?.hashCode() ?: 0
result = 31 * result + (groups?.hashCode() ?: 0)
result = 31 * result + (personProperties?.hashCode() ?: 0)
result = 31 * result + (groupProperties?.hashCode() ?: 0)
return result
}
}
)
Loading