Sorry, I am probably missing something.  Let me describe how I
understand your problem:

you've got V8 string which you'd like to write utf8 encoded into
socket several times and you don't want to pay for conversion.

Given that strings are immutable you can do the following:

First time you write the string, you turn it into externalized string.
 Your externalized string resource now holds two buffers---original
string and utf8 encoded.  So on next write, you'll check that string
is already external, fetch the resource from it, and write its utf8
encoded buffer into the socket.

If that sounds reasonable, you might find this helpful:
http://trac.webkit.org/browser/trunk/WebCore/bindings/v8/V8Binding.cpp

That converts v8 string into WebCore string.

yours,
anton.

On Thu, Apr 22, 2010 at 10:36 PM, Ryan Dahl <[email protected]> wrote:
> On Thu, Apr 22, 2010 at 10:18 AM, Anton Muhin <[email protected]> wrote:
>> On Thu, Apr 22, 2010 at 9:05 PM, Ryan Dahl <[email protected]> wrote:
>>> On Thu, Apr 22, 2010 at 12:19 AM, Anton Muhin <[email protected]> wrote:
>>>> Ryan,
>>>>
>>>> just a quick question: couldn't external strings solve the problem for
>>>> you?  They sound pretty much like Buffer you describe as far as I can
>>>> judge from your email.
>>>>
>>>> yours,
>>>> anton.
>>>
>>> I hadn't considered using external strings because I need to write
>>> utf-8 mostly. I suppose it would be possible to have a subclass of
>>> ExternalStringResource which allocated and stored its own reference to
>>> utf-8 encoded data when pushing a string to socket. This might work.
>>
>> Couldn't you use Ascii external strings, but actually store encoded
>> data?  If you only use it as a buffer, that should probably work fine,
>> but you'd better experiment.
>
> Maybe, but that doesn't solve the problem of associating encoded data
> with a string instance so that the next time the string is written to
> socket the encoded data is easily accessible. The benchmark I'm
> interested in fixing is the case where you write a large string many
> times to a socket.
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to