Repository: pixijs/pixijs
File: src/scene/container/utils/checkChildrenDidChange.ts (TypeScript)

Code before:
 * The changeId is a combination of the child's uid and _didChangeId, bitwise manipulated for uniqueness.
 * If a change is detected, it updates previousData and sets didChange to true.
 * The function returns a boolean indicating if any change was detected in the entire hierarchy of children.
 * @param container - the container to check for changes
 * @param previousData - the previous data from the last check made
 * @param previousData.data - the data array
 * @param previousData.index - the index of the data array
 * @param previousData.didChange - did the data change
 */
export function checkChildrenDidChange(
    container: Container,
    previousData: {
        data: number[];
        index: number;
        didChange: boolean;
    })
{
    const children = container.children;

    for (let i = 0; i < children.length; i++)
    {
        const child = children[i];

        const changeId = ((child.uid & 255) << 24)
            | ((child._didViewChangeTick % 0xfff) << 12)
            | (child._didContainerChangeTick % 0xfff);

        if (previousData.data[previousData.index] !== changeId)
        {
            previousData.data[previousData.index] = changeId;

            previousData.didChange = true;
        }

        previousData.index++;

        if (child.children.length)
        {
            checkChildrenDidChange(child, previousData);
        }
    }

    return previousData.didChange;
}


Review comment (suggestion):
```suggestion
            | ((child._didViewChangeTick & 0xfff) << 12)
            | (child._didContainerChangeTick & 0xfff);
```

Code after:
 * The changeId is a combination of the child's uid and _didChangeId, bitwise manipulated for uniqueness.
 * If a change is detected, it updates previousData and sets didChange to true.
 * The function returns a boolean indicating if any change was detected in the entire hierarchy of children.
 * @param container - the container to check for changes
 * @param previousData - the previous data from the last check made
 * @param previousData.data - the data array
 * @param previousData.index - the index of the data array
 * @param previousData.didChange - did the data change
 */
export function checkChildrenDidChange(
    container: Container,
    previousData: {
        data: number[];
        index: number;
        didChange: boolean;
    })
{
    const children = container.children;

    for (let i = 0; i < children.length; i++)
    {
        const child = children[i];

        const uid = child.uid;
        const didChange = ((child._didViewChangeTick & 0xffff) << 16) | (child._didContainerChangeTick & 0xffff);

        const index = previousData.index;

        if (previousData.data[index] !== uid || previousData.data[index + 1] !== didChange)
        {
            previousData.data[previousData.index] = uid;
            previousData.data[previousData.index + 1] = didChange;

            previousData.didChange = true;
        }

        previousData.index = index + 2;

        if (child.children.length)
        {
            checkChildrenDidChange(child, previousData);
        }
    }

    return previousData.didChange;
}