Closed Bug 168755 Opened 22 years ago Closed 22 years ago

[CasCadeS] inefficient code in SerializeExternalSheet

Categories

(SeaMonkey :: Composer, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: darin.moz, Assigned: glazou)

Details

this code should not be creating a standard-url.

924 function SerializeExternalSheet(sheet, href)
925 {
926   var nsuri =
Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
927   if (href)
928     nsuri.spec = href;
929   else
930     nsuri.spec = sheet.href;
931   var fileURL = nsuri.QueryInterface(Components.interfaces.nsIFileURL);
932   var localFile = fileURL.file;
933   var fileOuputStream =
Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);
934   try {
935     fileOuputStream.init(localFile, -1, -1, 0);

instead, you should replace it with something like the following:

var ios
  = Components.classes["@mozilla.org/network/io-service;1"]
              .getService(Components.interfaces.nsIIOService);
var fileHandler
  = ios.getProtocolHandler("file")
       .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
var localfile
  = fileHandler.getFileFromURLSpec(href);
Thanks for contributing and thanks for the hint, Darin :-)
Btw, the component for CaScadeS is Editor:Composer.
Changing. Accepting bug.
Status: NEW → ASSIGNED
Component: Editor: Core → Editor: Composer
OS: Linux → All
Hardware: PC → All
I was not fast enough : we now have a new component Editor:CSS Editor
Component: Editor: Composer → Editor: CSS Editor
code added to CaScadeS and ready to check-in, thanks Darin.
fix checked in trunk 11/07/2002 01:24
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Product: Browser → Seamonkey
Component: Composer CSS Editor → Composer
QA Contact: sujay → composer
You need to log in before you can comment on or make changes to this bug.