Changeset 95062 in webkit
- Timestamp:
- Sep 13, 2011 6:03:47 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r95061 r95062 1 2011-09-13 Leandro Pereira <leandro@profusion.mobi> 2 3 GTK DumpRenderTree uses inefficient idioms to iterate over G[S]Lists 4 https://bugs.webkit.org/show_bug.cgi?id=68024 5 6 Reviewed by Gustavo Noronha Silva. 7 8 Using g_list_count() and g_list_nth_data() together on a loop is 9 inneficient since they're both O(n). Iterate over lists in a saner 10 way. 11 12 * DumpRenderTree/gtk/DumpRenderTree.cpp: 13 (dumpHistoryItem): Reduce the scope for the 'kids' variable, and 14 iterate on it using g_list_next(). Free the list after done with it. 15 (dumpBackForwardListForWebView): Instead of appending (which is 16 expensive in GLists) history items and then iterating from the tail 17 of the itemsToPrint list, prepend items and walk forwards as usual. 18 (dumpBackForwardListForAllWebViews): Walk the list in a saner way, 19 remove the (unneeded) viewList variable. 20 1 21 2011-09-13 Ryosuke Niwa <rniwa@webkit.org> 2 22 -
trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
r94105 r95062 331 331 printf(" **nav target**"); 332 332 putchar('\n'); 333 GList* kids = webkit_web_history_item_get_children(item); 334 if ( kids) {333 334 if (GList* kids = webkit_web_history_item_get_children(item)) { 335 335 // must sort to eliminate arbitrary result ordering which defeats reproducible testing 336 kids = g_list_sort(kids, (GCompareFunc) compareHistoryItems); 337 for (unsigned i = 0; i < g_list_length(kids); i++) 338 dumpHistoryItem(WEBKIT_WEB_HISTORY_ITEM(g_list_nth_data(kids, i)), indent+4, FALSE); 336 for (GList* kid = g_list_sort(kids, (GCompareFunc) compareHistoryItems); kid; kid = g_list_next(kid)) { 337 WebKitWebHistoryItem* item = WEBKIT_WEB_HISTORY_ITEM(kid->data); 338 dumpHistoryItem(item, indent + 4, FALSE); 339 g_object_unref(item); 340 } 341 g_list_free(kids); 339 342 } 340 343 g_object_unref(item); … … 355 358 ASSERT(item != prevTestBFItem); 356 359 g_object_ref(item); 357 itemsToPrint = g_list_ append(itemsToPrint, item);360 itemsToPrint = g_list_prepend(itemsToPrint, item); 358 361 } 359 362 360 363 WebKitWebHistoryItem* currentItem = webkit_web_back_forward_list_get_current_item(bfList); 361 362 364 g_object_ref(currentItem); 363 itemsToPrint = g_list_append(itemsToPrint, currentItem); 364 365 gint currentItemIndex = g_list_length(itemsToPrint) - 1; 365 itemsToPrint = g_list_prepend(itemsToPrint, currentItem); 366 366 367 gint backListCount = webkit_web_back_forward_list_get_back_length(bfList); 367 368 for (int i = -1; i >= -(backListCount); i--) { … … 370 371 break; 371 372 g_object_ref(item); 372 itemsToPrint = g_list_ append(itemsToPrint, item);373 } 374 375 for ( int i = g_list_length(itemsToPrint) - 1; i >= 0; i--) {376 WebKitWebHistoryItem* item = WEBKIT_WEB_HISTORY_ITEM( g_list_nth_data(itemsToPrint, i));377 dumpHistoryItem(item, historyItemIndent, i == currentItemIndex);373 itemsToPrint = g_list_prepend(itemsToPrint, item); 374 } 375 376 for (GList* itemToPrint = itemsToPrint; itemToPrint; itemToPrint = g_list_next(itemToPrint)) { 377 WebKitWebHistoryItem* item = WEBKIT_WEB_HISTORY_ITEM(itemToPrint->data); 378 dumpHistoryItem(item, historyItemIndent, item == currentItem); 378 379 g_object_unref(item); 379 380 } 381 380 382 g_list_free(itemsToPrint); 381 383 printf("===============================================\n"); … … 388 390 389 391 // The view list is prepended. Reverse the list so we get the order right. 390 GSList* viewList = g_slist_reverse(webViewList); 391 for (unsigned i = 0; i < g_slist_length(viewList); ++i) 392 dumpBackForwardListForWebView(WEBKIT_WEB_VIEW(g_slist_nth_data(viewList, i))); 392 for (GSList* currentView = g_slist_reverse(webViewList); currentView; currentView = g_slist_next(currentView)) 393 dumpBackForwardListForWebView(WEBKIT_WEB_VIEW(currentView->data)); 393 394 } 394 395
Note: See TracChangeset
for help on using the changeset viewer.