Closed Bug 104929 Opened 23 years ago Closed 23 years ago

optimizations for nsStdURL.cpp

Categories

(Core :: Networking, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sspitzer, Assigned: sspitzer)

Details

Attachments

(1 file)

possible optimizations:  

1) use PL_strchr(str,'/'); instead of PL_strstr(str,"/");

2) instead of using PR_smprintf() to append the port,  use += and .AppendInt() 
(doesn't require a malloc and free)

I'll attach a patch.  I got an idea for GetSpec(), but I'll investigate first.
one idea for GetSpec() is to fix how we use GetPath()

currently, we do this:

    char* ePath = nsnull;
    rv = GetPath(&ePath);
    if NS_FAILED(rv) {
        CRTFREEIF(ePath);
        return rv;
    }
    if (ePath)
    {
        finalSpec += ePath;
    }

If we had something that just appended the path to the existing CAutoString, we
could avoid the allocation.
I thought darin was doing something close to a rewrite of nsStdUrl, you might
want to wait for him to comment before proceeding with this.
ok, I'll talk to darin.

another idea:

create a non-scriptable version of GetSpec() that takes a nsCAutoString ref, so
that the caller doesn't have to allocate and free. 

most callers seem to use the nsXPIDLCString, but if we passed in a ref to a
CString, we could avoid the malloc and free, assuming the spec was <= 63 bytes
(that's the thresh hold before we copy stack strings to the heap, right?)

seth: see bug 103916...

i'm working on redoing nsIURLParser to return offset and length integers,
instead of malloc'd copies of the URL segments.  with this new interface, i plan
to modify nsStdURL to hold a full normalized copy of the URL spec along with all
of the offset and length integers for each segment of the URL.  doing so should
improve GetSpec and Equals without there being any additional cost to the other
getters.  i have also confirmed that the setters are rarely called, so
optimizing them is of no value.
Comment on attachment 53653 [details] [diff] [review]
patch

sr=darin (not sure how soon i'll be generating a patch for the URL work i'm talking about, so perhaps it would be worthwhile to land this)
Attachment #53653 - Flags: superreview+
Comment on attachment 53653 [details] [diff] [review]
patch

r=sfraser
Attachment #53653 - Flags: review+
fixed.

all the fun stuff has moved to #103916.

Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: