Closed Bug 121943 Opened 23 years ago Closed 22 years ago

Optimise nsWyciwygChannel ::WriteToCache() to buffer data before writing to cache

Categories

(Core :: Layout, defect, P3)

x86
Windows 2000
defect

Tracking

()

RESOLVED FIXED
mozilla1.2beta

People

(Reporter: radha, Assigned: radha)

Details

Once patch to bug 35340 lands, the method nsWyciwygChannel::WriteToCache()
should  optimise the calls to cache.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.0
Priority: -- → P3
Target Milestone: mozilla1.0 → mozilla1.0.1
jst, you mentioned to me that this is not a trivial thing. Can you point me some
code snippet on what and how to take care of this. Thanks.
The problem here is that the WriteToCache() method takes a char * argument so we
must use NS_ConvertUCS2toUTF8() to convert the data that's written into UTF8.
This causes the written data to be copied into a temporary buffer, which will be
either on the stack or in the heap, depending on the length of the data that's
written. From looking at the implementation of WriteToCache() it seems unlikely
that we could avoid the string copying, but we could avoid ever having to
allocate a buffer to copy into, the logic for doing that should IMO live in the
WriteToCache() method though, and the WriteToCache() method should take a
nsAString& argument and not a char*. That change would also have the additional
benefit of not forcing the code to call strlen() on the written data, and this
way we're guaranteed to treat embedded null characters in a more sane way.
I don't believe I can get this into 1.0.1. 
Target Milestone: mozilla1.0.1 → mozilla1.2beta
Darin's fix for bug 151478 takes care of this bug. WriteToCache() no more takes
a char *.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.