Closed Bug 243250 Opened 20 years ago Closed 20 years ago

reduce size of nsStandardURL

Categories

(Core :: Networking, defect)

defect
Not set
minor

Tracking

()

VERIFIED FIXED
mozilla1.8alpha1

People

(Reporter: darin.moz, Assigned: darin.moz)

Details

Attachments

(1 file, 1 obsolete file)

nsStandardURL has a bunch of member variables that can each be represented by a
single bit or only a few bits each.  these should probably be combined into a
single PRUint32 to help reduce the size of nsStandardURL.

the member variables i'm thinking of include:

  mURLType
  mHostEncoding
  mSpecEncoding
  mMutable
  mSupportsFileURL

we could probably also pack mDefaultPort and mPort together.

these are easy things that we can do to reduce the size of nsStandardURL.  it's
also the case that there is some redundancy with the URLSegment member
variables.  many of these could be inferred from other values, so we could
probably save space by not storing all of these.  however, that's a much more
involved change.  this bug should just be able combining the fields i mentioned
above, which should save about 20 bytes per nsStandardURL.
...this bug should just be *about* combining...
Severity: normal → minor
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8alpha
actually, i wasn't thinking when i said that combining those members would save
20 bytes.  two of those members are PRPackedBool, and as for the port numbers...
-1 has significance, and so we'd need at least 17 bits to represent a port
properly.  we could do that with a PRUint16 plus a bit field, but then we'd be
checking the bit field before using the port value.

at any rate, it was easy enough to combine:

  mURLType
  mHostEncoding
  mSpecEncoding
  mMutable
  mSupportsFileURL

all into one PRUint32 by using bit-fields.  the patch is trivial.
Attached patch v1 patch (obsolete) — Splinter Review
Attached patch v1.1 patchSplinter Review
with better comment.
Attachment #148175 - Attachment is obsolete: true
Comment on attachment 148176 [details] [diff] [review]
v1.1 patch

hey boris, this is a trivial one to review.  if you really don't have time then
no problem... just let me know.  i just figured i'd ask you since you brought
up the performance impact of nsStandardURL today :-)
Attachment #148176 - Flags: superreview?(bzbarsky)
Attachment #148176 - Flags: review?(cbiesinger)
Comment on attachment 148176 [details] [diff] [review]
v1.1 patch

+    PRUint32 mHostEncoding    : 2; // eEncoding_xxx

hm... can you not use:
  nsEncodingType mHostEncoding : 2; ? that would be clearer, I think...

r=me either way
Attachment #148176 - Flags: review?(cbiesinger) → review+
Comment on attachment 148176 [details] [diff] [review]
v1.1 patch

sr=bzbarsky
Attachment #148176 - Flags: superreview?(bzbarsky) → superreview+
> hm... can you not use:
>   nsEncodingType mHostEncoding : 2; ? that would be clearer, I think...

I double check, but I think the last time I tried to do that I got an error or
warning from the compiler.
so, GCC 3.x doesn't have a problem with bitfields on an enum type.  not sure
what i was thinking....
bah, i like the idea that all of the bit fields use the same principle type name.
it makes the fields all line up, which has visual appeal, and doesn't require
someone to figure out that nsEncodingType is just an integer.  the other fields
like mURLType also take enumeration values, but we don't have an enumeration
type for it.  in short i prefer the patch as is ;-)
fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
for .cpp:

1.62darin%meer.net2004-05-11 11:58 fixes bug 243250 "reduce size of
nsStandardURL" r=biesi sr=bzbarsky

for .h:

1.19darin%meer.net2004-05-11 11:58 fixes bug 243250 "reduce size of
nsStandardURL" r=biesi sr=bzbarsky
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: