Open Bug 129807 Opened 23 years ago Updated 2 years ago

nssList_Clone() is O(n^2) if list->sortFunc is not NULL

Categories

(NSS :: Libraries, defect, P2)

Tracking

(Not tracked)

People

(Reporter: wtc, Unassigned)

Details

Attachments

(1 file)

nssList_Clone() first creates an empty list.  Then it
steps through the old list and calls nssList_Add() to
add the same data to the new list.

If list->sortFunc is not NULL, the old list is sorted and
nssList_Add() needs to invoke the sort function k times
when the new list has k elements.  To clone a list with
n elements, the sort function will be invoked
0 + 1 + 2 + ... + (n-1) = n*(n-1)/2 times.

If list->sortFunc is NULL, nssList_Clone() is O(n)
because nssList_Add() is O(1).
sigh.  The list code is really not good, I wrote it to solve a problem, then
overused it.  I've been thinking of ways to remove dependencies on it (i.e.,
better ways of solving the problems that nssList is currently being used for).

Should this be a 3.4.1 bug?  The obvious fix is to clone the list directly
instead of using nssList_Add.
Yes, cloning the list directly is the solution.

Setting target milestone 3.4.1, priority P2.
Priority: -- → P2
Target Milestone: --- → 3.4.1
Changed the QA contact to Bishakha.
QA Contact: sonja.mirtitsch → bishakhabanerjee
Set target milestone to NSS 3.5.
Target Milestone: 3.4.1 → 3.5
Target Milestone: 3.5 → 3.7
Moved to target milestone 3.8 because the original
NSS 3.7 release has been renamed 3.8.
Target Milestone: 3.7 → 3.8
Remove target milestone of 3.8, since these bugs didn't get into that release.
Target Milestone: 3.8 → ---
QA Contact: bishakhabanerjee → jason.m.reid
Assignee: bugz → nobody
QA Contact: jason.m.reid → libraries
Version: 3.4 → 3.3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: