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.
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
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
editorbase- -> sfraser
Assignee: jfrancis → sfraser
Whiteboard: editorbase → editorbase-
Simon do you intend to update/check these patches in ?
Assignee: sfraser_bugs → mozeditor
QA Contact: bugzilla
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.