WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#7353 closed defect (bug) (fixed)

improve walker class

Reported by: hailin Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

walker class has the same issue as described in page_rows() in #7286.

Basically we can not guarantee worst case performance, which may take up to
O(number of top level elements * number of children elements).

The proposed fix has O(N) complexity in the worst, best, and average case.

Attachments (1)

7353_improve_walker.diff (3.9 KB) - added by hailin 6 years ago.
patch

Download all attachments as: .zip

Change History (7)

hailin6 years ago

patch

comment:1 hailin6 years ago

tested it to make sure it produces exactly the same output as existing logic.

comment:2 westi6 years ago

Is it possible to write unit-tests for the walker class so we have ongoing testability of the output to future proof us?

comment:3 follow-up: jacobsantos6 years ago

There should already be test cases for the Walker classes. That said, you can never have too many test cases. I point it out, because they can be used as examples for developing more test cases.

comment:4 in reply to: ↑ 3 westi6 years ago

Replying to jacobsantos:

There should already be test cases for the Walker classes. That said, you can never have too many test cases. I point it out, because they can be used as examples for developing more test cases.

Looking through my checkout of the unit-tests I couldn't find any walker class specific tests (unless I am looking in the wrong place).

comment:5 santosj6 years ago

Okay, I was wrong. It did have it at one point, I'm not sure what happened to my test suite that I sent Alex. I think with the improvements it was probably set aside or didn't fit anymore.

I'll send him a email and see what's up. The test suite I wrote only covers Walker_Category or some of the child classes of the Walker class, so it won't be all that much use in this case.

I also can't view the revision log online (that I know of), so I'm unaware of where it could have went. At home, I'm currently an earlier revision, so I can check there before I continue.

However, since there aren't currently any test cases, then there should be. I'll try to find my old test suite and improve upon it from there.

comment:6 ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8494]) Walker improvements from hailin. fixes #7353

Note: See TracTickets for help on using tickets.