Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 6b809c9

Browse files
authored
Merge pull request #123 from SLNE-Development/copilot/sub-pr-113-again
Replace Stack with ArrayDeque in pruneEmptyAncestors
2 parents 28f5fb2 + 14214ed commit 6b809c9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/player/ppdc/PersistentPlayerDataContainerImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,20 @@ open class PersistentPlayerDataContainerImpl(
215215
) {
216216
if (pathToDeepestParent.isEmpty()) return
217217

218-
val stack = Stack<Pair<FastCompoundBinaryTag, String>>()
218+
val stack = ArrayDeque<Pair<FastCompoundBinaryTag, String>>()
219219
var current: FastCompoundBinaryTag = root
220220

221221
for (segment in pathToDeepestParent) {
222222
val childTag = current.getCompound(segment, null) ?: return
223223
val childFast = childTag as? FastCompoundBinaryTag ?: childTag.fast()
224224

225225
current.put(segment, childFast)
226-
stack.push(current to segment)
226+
stack.addLast(current to segment)
227227
current = childFast
228228
}
229229

230230
while (stack.isNotEmpty()) {
231-
val (parent, key) = stack.pop()
231+
val (parent, key) = stack.removeLast()
232232
val child = parent.getCompound(key, null) ?: continue
233233
if (child.size() == 0) {
234234
parent.remove(key)

0 commit comments

Comments
 (0)