Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haxe.Serializer cleanup #11864

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
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
22 changes: 6 additions & 16 deletions std/haxe/Serializer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ class Serializer {

/**
Serializes `v`.

All haxe-defined values and objects with the exception of functions can
be serialized. Serialization of external/native objects is not
guaranteed to work.

The values of `this.useCache` and `this.useEnumIndex` may affect
serialization output.
**/
Expand Down Expand Up @@ -379,8 +379,6 @@ class Serializer {
}
#end
case TClass(c):
if (useCache)
cache.pop();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I'm missing some really intricate detail here or if this is really just silly. Nothing seems to happen between this pop and the push operations below that could access the cache, so I don't see why this was here.

if (
#if flash
try
Expand All @@ -396,15 +394,11 @@ class Serializer {
#end) {
buf.add("C");
serializeString(Type.getClassName(c));
if (useCache)
cache.push(v);
v.hxSerialize(this);
buf.add("g");
} else {
buf.add("c");
serializeString(Type.getClassName(c));
if (useCache)
cache.push(v);
#if flash
serializeClassFields(v, c);
#else
Expand Down Expand Up @@ -433,11 +427,9 @@ class Serializer {
serializeFields(v);
}
case TEnum(e):
if (useCache) {
if (serializeRef(v))
return;
cache.pop();
Simn marked this conversation as resolved.
Show resolved Hide resolved
}
if (useCache && serializeRef(v))
return;

buf.add(useEnumIndex ? "j" : "w");
serializeString(Type.getEnumName(e));
#if neko
Expand Down Expand Up @@ -539,8 +531,6 @@ class Serializer {
for (i in 2...l)
serialize(v[i]);
#end
if (useCache)
cache.push(v);
case TFunction:
throw "Cannot serialize function";
default:
Expand Down Expand Up @@ -576,7 +566,7 @@ class Serializer {

/**
Serializes `v` and returns the String representation.

This is a convenience function for creating a new instance of
Serializer, serialize `v` into it and obtain the result through a call
to `toString()`.
Expand Down
Loading