Closed Bug 201782 Opened 21 years ago Closed 8 years ago

Reduce NS_LITERAL_STRING usage in editor to reduce code size

Categories

(Core :: DOM: Editor, defect)

defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: sfraser_bugs, Unassigned)

Details

(Keywords: memory-footprint, Whiteboard: editorbase-)

Attachments

(3 files)

nsAString::Equals(NS_LITERAL_STRING("foo")) produces very verbose code.
Converting  to narrow (UTF8) strings and comparing with a literal C string
shrinks the code considerably (see attached data). Since we're only ever
concerned with attribute names in ASCII in editor, maybe we should consider
converting all attribute strings to 8-bit.
Numbers on the left are compiled size of this method in bytes. Diff shows
function size before, and after the patch. For example:

-    6652 t nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>&)
+    2088 t nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>&)

-    5476 t nsHTMLEditRules::ApplyBlockStyle(nsCOMArray<nsIDOMNode>&, nsAString
const*)
+    2476 t nsHTMLEditRules::ApplyBlockStyle(nsCOMArray<nsIDOMNode>&, nsAString
const*)

Effects of these changes on library size in an opt build:
-rwxr-xr-x  1 smfr  staff  880004 Apr 12 10:43 libeditor_patched.dylib
-rwxr-xr-x  1 smfr  staff  895532 Apr 12 10:11 libeditor_original.dylib
This patch contains more cleanup, not just related to string usage. Changes
include:
* Make data const where possible
* More efficient member var packing (PRPackedBool)
* Tidy up ctor member intialization to fix warnings
* Remove unused static gInstanceCounts
* Clean up nsEditor::GetTextNodeTag (what was buster thinking??)
* Removed the sParserService static in nsHTMLEditor. This had knock-on effects
  of making a bunch of methods non-static, which percolates into the
  nsHTMLEditRules and nsWSRunObject. NodeIsBlockStatic was removed.

Lib size with these changes:
-rwxr-xr-x  1 smfr  staff  895532 Apr 12 10:11 libeditor_orig.dylib
-rwxr-xr-x  1 smfr  staff  873924 Apr 12 14:40 libeditor_patched.dylib
Whiteboard: editorbase
editorbase-

-> sfraser
Assignee: jfrancis → sfraser
Keywords: footprint
Whiteboard: editorbase → editorbase-
Simon do you intend to update/check these patches in ?
No.
Assignee: sfraser_bugs → mozeditor
QA Contact: bugzilla
QA Contact: editor
Assignee: mozeditor → nobody
The Equals(NS_LITERAL_*(...)) changes are no longer relevant, and editor/ has changed so much in the past decade or so that the size patches are probably irrelevant as well.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: