Benchmark:

admin/structure/block

Edge Insider Build:
Before: 147ms
After: 12ms

Chrome Canary :
Before: 6ms
After: 2ms

admin/structure/menu/manage/tools (with 700 menu items)

Edge Insider Build:
Before: 2437ms
After: 202ms

Chrome Canary :
Before: 87ms
After:20ms

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

droplet created an issue. See original summary.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

Oh! good catch.

No issue here. Doesn't change the logic, just separate selection and initial filtering.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/misc/tabledrag.js
@@ -1162,10 +1162,11 @@
-    $(this.table).find('> tbody > tr.draggable:visible, > tr.draggable:visible')
-      .removeClass('odd even')
-      .filter(':odd').addClass('even').end()
-      .filter(':even').addClass('odd');
+    // This is performance optimized code. Benchmark is required on code refactoring.
+    $(this.table).find('> tbody > tr.draggable, > tr.draggable')
+      .filter(':visible')
+      .filter(':odd').removeClass('odd').addClass('even').end()
+      .filter(':even').removeClass('even').addClass('odd');

This needs some 80 char wrapping which I was about to do myself, but better yet can we explain the added comment a bit better. I would say lot of things in PHP/JS are performance optimized and we don't say this in code comments :)

droplet’s picture

Issue summary: View changes

Any Suggestions? If not, just drop it. the comments helped CORE committers

Gábor Hojtsy’s picture

I would personally drop it, we usually don't explain these tricks :)

droplet’s picture

Status: Needs work » Needs review
FileSize
803 bytes
nod_’s picture

Status: Needs review » Reviewed & tested by the community

:)

Gábor Hojtsy’s picture

Title: Huge Performance Improve: Drupal.tableDrag.restripeTable (10x faster) » Make Drupal.tableDrag.restripeTable 10x faster

  • Gábor Hojtsy committed c714da3 on 8.3.x
    Issue #2876224 by droplet: Make Drupal.tableDrag.restripeTable 10x...

  • Gábor Hojtsy committed 186dcc0 on 8.4.x
    Issue #2876224 by droplet: Make Drupal.tableDrag.restripeTable 10x...
Gábor Hojtsy’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Fixed

Thanks, committed to 8.4.x and cherry-picked to 8.3.x given that this was a simple self-contained performance improvement that has no side effect whatsoever :)

Wim Leers’s picture

NICE.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.