Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#15931 closed optimization (fixed)

Avoids numerous call to realloc in wxHtmlTableCell::ReallocRows

Reported by: R.U.10 Owned by:
Priority: normal Milestone:
Component: wxHtml Version: dev-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

For a HTML table which contains numerous rows, the call to wxHtmlTableCell::ReallocRows results in a repeated call to realloc() which is a time consuming operation, increases the memory fragmentation and generates erratic behavior at least on XP.

Attachments (1)

wxHtmlTableCell_ReallocRows.patch download (1.5 KB) - added by R.U.10 7 months ago.

Download all attachments as: .zip

Change History (5)

Changed 7 months ago by R.U.10

comment:1 Changed 7 months ago by VZ

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

(In [75742]) Reduce the number of realloc() calls in wxHtmlTableCell.

Don't call realloc() after adding each row, this is horribly inefficient, so
preallocate more memory to avoid this.

Closes #15931.

comment:2 follow-up: Changed 7 months ago by VZ

(In [75746]) Reduce the number of realloc() calls in wxHtmlTableCell.

Don't call realloc() after adding each row, this is horribly inefficient, so
preallocate more memory to avoid this.

Closes #15931.

comment:3 in reply to: ↑ 2 Changed 7 months ago by neis

Replying to VZ:

(In [75746]) Reduce the number of realloc() calls in wxHtmlTableCell.

Don't call realloc() after adding each row, this is horribly inefficient, so
preallocate more memory to avoid this.

Instead of having this complexity in one more place, shouldn't that be a wxVector or wxArray of rows rather than a pointer/C-array?

comment:4 Changed 7 months ago by vadz

I'd welcome this change too, of course, it's true that wxVector already uses some amortized allocation strategy. But it's less important and your change didn't come with a patch :-)

Note: See TracTickets for help on using tickets.