diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-01-10 20:49:22 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-01-10 20:49:22 +0000 |
commit | 3611f253f6fdfa4954d374ab85ddaa7f799c130c (patch) | |
tree | 6cb4344f6a694ab94b857b59c92f26efe7d8d488 | |
parent | 55cb78b785360bb349e6a60e965dfd4dd2058597 (diff) | |
download | libbu++-3611f253f6fdfa4954d374ab85ddaa7f799c130c.tar.gz libbu++-3611f253f6fdfa4954d374ab85ddaa7f799c130c.tar.bz2 libbu++-3611f253f6fdfa4954d374ab85ddaa7f799c130c.tar.xz libbu++-3611f253f6fdfa4954d374ab85ddaa7f799c130c.zip |
The FString is much more optimized, and hopefully still works accurately.
Diffstat (limited to '')
-rw-r--r-- | src/fbasicstring.h | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index 9378c1c..bf43502 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -237,6 +237,7 @@ namespace Bu | |||
237 | using SharedCore<MyType, Core >::_hardCopy; | 237 | using SharedCore<MyType, Core >::_hardCopy; |
238 | 238 | ||
239 | public: // Iterators | 239 | public: // Iterators |
240 | struct iterator; | ||
240 | typedef struct const_iterator | 241 | typedef struct const_iterator |
241 | { | 242 | { |
242 | friend class FBasicString<chr, nMinSize, chralloc, chunkalloc>; | 243 | friend class FBasicString<chr, nMinSize, chralloc, chunkalloc>; |
@@ -258,7 +259,7 @@ namespace Bu | |||
258 | { | 259 | { |
259 | } | 260 | } |
260 | 261 | ||
261 | const_iterator( const iterator &i ) : | 262 | const_iterator( const struct iterator &i ) : |
262 | pChunk( i.pChunk ), | 263 | pChunk( i.pChunk ), |
263 | iPos( i.iPos ) | 264 | iPos( i.iPos ) |
264 | { | 265 | { |
@@ -776,20 +777,8 @@ namespace Bu | |||
776 | if( !pData ) return; | 777 | if( !pData ) return; |
777 | long nLen; | 778 | long nLen; |
778 | for( nLen = 0; pData[nLen] != (chr)0; nLen++ ) { } | 779 | for( nLen = 0; pData[nLen] != (chr)0; nLen++ ) { } |
779 | if( nLen == 0 ) | ||
780 | return; | ||
781 | |||
782 | if( core->pLast->nLength < nMinSize ) | ||
783 | { | ||
784 | // Put things here, good things | ||
785 | // yeah...spare space block mapping | ||
786 | } | ||
787 | 780 | ||
788 | Chunk *pNew = core->newChunk( nLen ); | 781 | append( pData, 0, nLen ); |
789 | cpy( pNew->pData, pData, nLen ); | ||
790 | |||
791 | _hardCopy(); | ||
792 | core->appendChunk( pNew ); | ||
793 | } | 782 | } |
794 | 783 | ||
795 | /** | 784 | /** |
@@ -799,15 +788,7 @@ namespace Bu | |||
799 | */ | 788 | */ |
800 | void append( const chr *pData, long nLen ) | 789 | void append( const chr *pData, long nLen ) |
801 | { | 790 | { |
802 | if( nLen == 0 ) | 791 | append( pData, 0, nLen ); |
803 | return; | ||
804 | |||
805 | Chunk *pNew = core->newChunk( nLen ); | ||
806 | |||
807 | cpy( pNew->pData, pData, nLen ); | ||
808 | |||
809 | _hardCopy(); | ||
810 | core->appendChunk( pNew ); | ||
811 | } | 792 | } |
812 | 793 | ||
813 | /** | 794 | /** |
@@ -818,15 +799,37 @@ namespace Bu | |||
818 | */ | 799 | */ |
819 | void append( const chr *pData, long nStart, long nLen ) | 800 | void append( const chr *pData, long nStart, long nLen ) |
820 | { | 801 | { |
821 | if( nLen == 0 ) | 802 | if( !pData ) return; |
803 | if( nLen <= 0 ) | ||
822 | return; | 804 | return; |
823 | 805 | ||
824 | Chunk *pNew = core->newChunk( nLen ); | 806 | pData += nStart; |
825 | |||
826 | cpy( pNew->pData, pData+nStart, nLen ); | ||
827 | 807 | ||
828 | _hardCopy(); | 808 | _hardCopy(); |
829 | core->appendChunk( pNew ); | 809 | |
810 | if( core->pLast && core->pLast->nLength < nMinSize ) | ||
811 | { | ||
812 | int nAmnt = nMinSize - core->pLast->nLength; | ||
813 | if( nAmnt > nLen ) | ||
814 | nAmnt = nLen; | ||
815 | cpy( | ||
816 | core->pLast->pData+core->pLast->nLength, | ||
817 | pData, | ||
818 | nAmnt | ||
819 | ); | ||
820 | pData += nAmnt; | ||
821 | core->pLast->nLength += nAmnt; | ||
822 | nLen -= nAmnt; | ||
823 | core->nLength += nAmnt; | ||
824 | } | ||
825 | |||
826 | if( nLen > 0 ) | ||
827 | { | ||
828 | Chunk *pNew = core->newChunk( nLen ); | ||
829 | cpy( pNew->pData, pData, nLen ); | ||
830 | core->appendChunk( pNew ); | ||
831 | // core->nLength += nLen; | ||
832 | } | ||
830 | } | 833 | } |
831 | 834 | ||
832 | /** | 835 | /** |
@@ -855,7 +858,7 @@ namespace Bu | |||
855 | */ | 858 | */ |
856 | void append( const MyType & sData ) | 859 | void append( const MyType & sData ) |
857 | { | 860 | { |
858 | append( sData.getStr(), sData.getSize() ); | 861 | append( sData.getStr(), 0, sData.getSize() ); |
859 | } | 862 | } |
860 | 863 | ||
861 | /** | 864 | /** |
@@ -866,7 +869,7 @@ namespace Bu | |||
866 | */ | 869 | */ |
867 | void append( const MyType & sData, long nLen ) | 870 | void append( const MyType & sData, long nLen ) |
868 | { | 871 | { |
869 | append( sData.getStr(), nLen ); | 872 | append( sData.getStr(), 0, nLen ); |
870 | } | 873 | } |
871 | 874 | ||
872 | /** | 875 | /** |