Reduce NS_LITERAL_STRING usage in editor to reduce code size

RESOLVED INCOMPLETE

Status

()

Core
Editor
RESOLVED INCOMPLETE
15 years ago
2 years ago

People

(Reporter: Simon Fraser, Unassigned)

Tracking

({footprint})

Trunk
footprint
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: editorbase-)

Attachments

(3 attachments)

(Reporter)

Description

15 years ago
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.
(Reporter)

Comment 1

15 years ago
Created attachment 120320 [details] [diff] [review]
Some Piecemeal string changes in editor
(Reporter)

Comment 2

15 years ago
Created attachment 120321 [details]
Diffs of 'nm' output showing changes in code size

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
(Reporter)

Comment 3

15 years ago
Created attachment 120336 [details] [diff] [review]
More extensive editor code cleanup

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

Updated

15 years ago
Whiteboard: editorbase
editorbase-

-> sfraser
Assignee: jfrancis → sfraser
Keywords: footprint
Whiteboard: editorbase → editorbase-
Simon do you intend to update/check these patches in ?
(Reporter)

Comment 6

12 years ago
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
Last Resolved: 2 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.