If tests happen to pass then I will bench this. By the use of the (known to be very fast) array_pop function and [] operator, I have implemented a simple stack to remove the recurse from drupal_render.

Comments

chx’s picture

StatusFileSize
new2.35 KB

For easier review, I attached a patch without the whitespace changes.

sun’s picture

chx’s picture

StatusFileSize
new2.97 KB
new9.08 KB

Added lots of comments and a missing reference in the for header.

Status: Needs review » Needs work

The last submitted patch failed testing.

sun’s picture

Status: Needs work » Needs review
Issue tags: +Performance, +D7 API clean-up

.

chx’s picture

Issue tags: -Performance, -D7 API clean-up
StatusFileSize
new8.82 KB
new2.71 KB

Replaced the ugly for loop with a much nicer do.

chx’s picture

Status: Needs review » Needs work
Issue tags: +Performance, +D7 API clean-up

Oh well. I presume we need an output stack too.

sun’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch failed testing.

sun’s picture

Status: Needs work » Needs review
StatusFileSize
new8.59 KB

Note that #601806: drupal_render() should not set default element properties when #type is not known contains some further optimizations to drupal_render() is about to be committed. (boils down to: skipping empty elements and not setting any global defaults)

--

Playing around with this, I think it is more complex than it needs to be.

If you disagree, then at least take over the comments. ;)

Status: Needs review » Needs work

The last submitted patch failed testing.

Crell’s picture

Subscribing.

chx’s picture

Sun, your approach is even more broken than mine :) I will take the comments, thanks.

chx’s picture

Assigned: chx » Unassigned
Issue summary: View changes
gisle’s picture

Issue tags: -D7 API clean-up +API clean-up

Official tag is "API clean-up" - https://www.drupal.org/node/1207020

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.