Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Genericifying the trace -> replay code #23

Copy link
Copy link
@greggman

Description

@greggman
Issue body actions

There's lots of trace data that's like

{
   someField: number;
   someOtherField: number;
   textureSerial: number;
}

And there is code that converts textureSerial: number to texture: someReplayTexture

It made me wonder if there would be any benefit from trying to make that code just scan every trace object for xxxSerial and then do auto convert. Something like

function deserilize(traceObject, replay) {
    const kSerial = 'Serial';
    for (const [key, value] of Object.entries(traceObject)) {
         if (Array.isArray(value)) {
             for (const elem of value) {
                 if (typeof elem === 'object') {
                     deserialize(elem, replay);
                 }
             }
         } else if (typeof value === 'object') {
             deserialize(value, replay)
         } else if (key.endsWith(kSerial)) {
             const type = key.substring(0, key.length - kSerial.length);
             traceObject[type] = replay[`${type}s`][value];
             delete traceObject[key];  // probably needs to be moved out of loop
         }
    }
}

I don't know if that would be generic enough or if there'd be so many exceptions it's not worth it.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.