[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-freeqt
Subject:    [freeqt] QString (or: What's wrong with this delete[]??)
From:       Florin Boariu <florin () hermes ! blitz ! net>
Date:       1998-09-30 16:25:28
[Download RAW message or body]

Hi.

Maybe I'm missing the point (I consider myself a C/C++ beginner) - if
so, please tell me - but from what I've read your main problem is of how
to store strings. There can be 8, 16, 24 and 32 bit strings. You don't
want to use 32-bit strings, for example, for storing 8-bit chars. Is
that the point?

No, I don't know the harmony-internals, I don't know the QString-class
but if I was to start from scratch I'd do this like this:

let's assume I have the following string, where <8> stands for 8-bit
chars and <32> <24> <16> for another (Unicode?) characters.

<8><8><8><32><16><16><16><8><8><8><8> etc.

I wouldn't save it in one memory block but in more, like:

the_buffer
        {
                data1 {<8><8><8>}          // 3 characters/glyphs/whatever
                data2 {<32>}               // 1 character
                data3 {<16><16><16>}       // 3 characters
                data4 {<8><8><8><8>}       // 4 characters
        }
the_types
        {
                type_of_data1 = 8;
                type_of_data2 = 32;
                type_of_data3 = 16;
                type_of_data4 = 8;
        }

I hope you see what I mean. You split the buffer you have to save in as
many different data blocks as how often the contents switch btw.
8/16/24/32. If an operation must be ferformed on substring 3-10, you
simply look for the third element and perform the operation till element
nr. 10-3 or, if element 10-3 is not in the same block anymore, till the
end of the block and then you continue in the next block...

I don't think this will slow things up too much (you don't switch
"modes" every 2nd glyph, do you?), but it can save a lot of space,
especially if you're using big strings that can be split in big data
blocks.

Well, that's my oppinion on that. (Don't shoot me if I'm totally
off-topic :)

regards,
florin.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic