From 8947c3a3bc55523e723923bb3c0166264d9387b3 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 2 Jun 2025 21:40:46 +0530 Subject: [PATCH] refactor: make `CommentNode#toString` non-recursive --- .../msfjarvis/claw/common/comments/CommentNode.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt index f03a747d..7adaf8a3 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt @@ -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)" + } }