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

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

The deepCopy function in PersistentPlayerDataContainerViewImpl was creating a new ObjectArrayList for each nested CompoundBinaryTag level, causing O(n) allocations where n is the nesting depth.

Changes:

  • Replace list materialization with iterator-based traversal
    • Remove entriesOf() helper that created intermediate ObjectArrayList instances
    • Store Iterator<Map.Entry<String, out BinaryTag>> directly in Frame data class
    • Replace index-based iteration with hasNext()/next() pattern
  • Remove unused ObjectArrayList import

Before:

fun entriesOf(tag: CompoundBinaryTag): List<Pair<String, BinaryTag>> {
    val list = ObjectArrayList<Pair<String, BinaryTag>>(tag.size())
    tag.forEach { (k, v) -> list.add(k to v) }
    return list
}
// Called once per nested level

After:

Frame(
    iterator = value.iterator(),  // No intermediate allocation
    builder = CompoundBinaryTag.builder(),
    parent = top,
    parentKey = key
)

This eliminates all intermediate allocations during deep copy traversal.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.slne.dev
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx4G -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/gradle-daemon-main-8.14.3.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/agents/gradle-instrumentation-agent-8.14.3.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.14.3 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] WIP address feedback on persistent player data tracking Optimize deepCopy to eliminate repeated allocations for nested structures Nov 1, 2025
Copilot AI requested a review from twisti-dev November 1, 2025 14:22
@twisti-dev twisti-dev closed this Nov 1, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in surf-cloud Nov 1, 2025
@twisti-dev twisti-dev deleted the copilot/sub-pr-113-again branch November 1, 2025 14:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants