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

[v3.8.6] Optimize code size for pointer-event-dispatcher.ts. #18220

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
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
12 changes: 7 additions & 5 deletions cocos/2d/event/pointer-event-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PointerEventDispatcher implements IEventDispatcher {
return true;
}

public addPointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
private addPointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
if (this._inDispatchCount === 0) {
if (!this._pointerEventProcessorList.includes(pointerEventProcessor)) {
this._pointerEventProcessorList.push(pointerEventProcessor);
Expand All @@ -88,7 +88,7 @@ class PointerEventDispatcher implements IEventDispatcher {
js.array.remove(this._processorListToRemove, pointerEventProcessor);
}

public removePointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
private removePointerEventProcessor (pointerEventProcessor: NodeEventProcessor): void {
if (this._inDispatchCount === 0) {
js.array.remove(this._pointerEventProcessorList, pointerEventProcessor);
this._isListDirty = true;
Expand All @@ -98,7 +98,7 @@ class PointerEventDispatcher implements IEventDispatcher {
js.array.remove(this._processorListToAdd, pointerEventProcessor);
}

public dispatchEventMouse (eventMouse: EventMouse): boolean {
private dispatchEventMouse (eventMouse: EventMouse): boolean {
this._inDispatchCount++;
this._sortPointerEventProcessorList();
const pointerEventProcessorList = this._pointerEventProcessorList;
Expand All @@ -122,7 +122,7 @@ class PointerEventDispatcher implements IEventDispatcher {
return dispatchToNextEventDispatcher;
}

public dispatchEventTouch (eventTouch: EventTouch): boolean {
private dispatchEventTouch (eventTouch: EventTouch): boolean {
this._inDispatchCount++;
this._sortPointerEventProcessorList();
const pointerEventProcessorList = this._pointerEventProcessorList;
Expand Down Expand Up @@ -236,7 +236,9 @@ class PointerEventDispatcher implements IEventDispatcher {
if (p1.cachedCameraPriority !== p2.cachedCameraPriority) {
return p2.cachedCameraPriority - p1.cachedCameraPriority;
}
let n1: Node | null = node1; let n2: Node | null = node2; let ex = false;
let n1: Node | null = node1;
let n2: Node | null = node2;
let ex = false;
while (n1!.parent?.uuid !== n2!.parent?.uuid) {
n1 = n1?.parent?.parent === null ? (ex = true) && node2 : n1 && n1.parent;
n2 = n2?.parent?.parent === null ? (ex = true) && node1 : n2 && n2.parent;
Expand Down
Loading