refactor: make CommentNode#toString non-recursive

This commit is contained in:
Harsh Shandilya 2025-06-02 21:40:46 +05:30
parent 16cc116b00
commit 8947c3a3bc

View file

@ -38,9 +38,9 @@ internal data class CommentNode(
}
/**
* [CommentNode.equals] and [CommentNode.hashCode] are hand-rolled to drop the
* [CommentNode.parent] field from the comparison since it's possible for there to be cycles in
* this comparison check. For our purposes we're fine with foregoing the field.
* [CommentNode.equals], [CommentNode.toString] and [CommentNode.hashCode] are hand-rolled to drop
* the [CommentNode.parent] field from the comparison since it's possible for there to be cycles
* in this comparison check. For our purposes we're fine with foregoing the field.
*/
override fun equals(other: Any?): Boolean {
if (this === other) return true
@ -65,4 +65,10 @@ internal data class CommentNode(
result = 31 * result + isExpanded.hashCode()
return result
}
override fun toString(): String {
return "CommentNode(comment=${comment.shortId}, isPostAuthor=$isPostAuthor, " +
"children=${children.size}, isUnread=$isUnread, indentLevel=$indentLevel, " +
"isExpanded=$isExpanded)"
}
}