Changeset 846 for trunk/src/corelib/tools/qbytearray.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/corelib/tools/qbytearray.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 47 47 #include "qlocale.h" 48 48 #include "qlocale_p.h" 49 #include "qunicodetables_p.h"50 49 #include "qscopedpointer.h" 51 50 #include <qdatastream.h> … … 154 153 This function assumes that \a dst is at least \a len characters 155 154 long. 155 156 157 158 156 159 157 160 \sa qstrcpy() … … 847 850 \l{implicitly shared}. This makes returning a QByteArray from a 848 851 function very fast. If a shared instance is modified, it will be 849 copied (copy-on-write), and that takes\l{linear time}.852 copied (copy-on-write), \l{linear time}. 850 853 851 854 \sa operator=() … … 1062 1065 */ 1063 1066 1067 1068 1069 1070 1071 1064 1072 /*! \fn char QByteArray::at(int i) const 1065 1073 … … 1178 1186 \snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 12 1179 1187 1180 This operation is typically very fast (\l{constant time}), 1181 because QByteArray preallocates extra space at the end of the 1182 character data so it can grow without reallocating the entire 1183 data each time. 1188 Note: QByteArray is an \l{implicitly shared} class. Consequently, 1189 if \e this is an empty QByteArray, then \e this will just share 1190 the data held in \a ba. In this case, no copying of data is done, 1191 taking \l{constant time}. If a shared instance is modified, it will 1192 be copied (copy-on-write), taking \l{linear time}. 1193 1194 If \e this is not an empty QByteArray, a deep copy of the data is 1195 performed, taking \l{linear time}. 1196 1197 This operation typically does not suffer from allocation overhead, 1198 because QByteArray preallocates extra space at the end of the data 1199 so that it may grow without reallocating for each append operation. 1184 1200 1185 1201 \sa append(), prepend() … … 1466 1482 Note: QByteArray is an \l{implicitly shared} class. Consequently, 1467 1483 if \e this is an empty QByteArray, then \e this will just share 1468 the data held in \a ba. In this case, no copying of data is done. 1484 the data held in \a ba. In this case, no copying of data is done, 1485 taking \l{constant time}. If a shared instance is modified, it will 1486 be copied (copy-on-write), taking \l{linear time}. 1487 1488 If \e this is not an empty QByteArray, a deep copy of the data is 1489 performed, taking \l{linear time}. 1469 1490 1470 1491 \sa append(), insert() … … 1539 1560 This is the same as insert(size(), \a ba). 1540 1561 1541 This operation is typically very fast (\l{constant time}),1542 because QByteArray preallocates extra space at the end of the1543 character data so it can grow without reallocating the entire1544 data each time.1545 1546 1562 Note: QByteArray is an \l{implicitly shared} class. Consequently, 1547 1563 if \e this is an empty QByteArray, then \e this will just share 1548 the data held in \a ba. In this case, no copying of data is done. 1564 the data held in \a ba. In this case, no copying of data is done, 1565 taking \l{constant time}. If a shared instance is modified, it will 1566 be copied (copy-on-write), taking \l{linear time}. 1567 1568 If \e this is not an empty QByteArray, a deep copy of the data is 1569 performed, taking \l{linear time}. 1570 1571 This operation typically does not suffer from allocation overhead, 1572 because QByteArray preallocates extra space at the end of the data 1573 so that it may grow without reallocating for each append operation. 1549 1574 1550 1575 \sa operator+=(), prepend(), insert() … … 1788 1813 } else { 1789 1814 QByteArray copy(after); 1790 // ### optimi se me1815 // ### optimie me 1791 1816 remove(pos, len); 1792 1817 return insert(pos, copy); … … 1797 1822 1798 1823 \overload 1824 1825 1826 1827 1828 1799 1829 */ 1800 1830 QByteArray &QByteArray::replace(int pos, int len, const char *after) 1801 1831 { 1802 int alen = qstrlen(after); 1832 return replace(pos,len,after,qstrlen(after)); 1833 } 1834 1835 /*! \fn QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) 1836 1837 \overload 1838 1839 Replaces \a len bytes from index position \a pos with \a alen bytes 1840 from the string \a after. \a after is allowed to have '\0' characters. 1841 1842 \since 4.7 1843 */ 1844 QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) 1845 { 1803 1846 if (len == alen && (pos + len <= d->size)) { 1804 1847 detach(); … … 1811 1854 } 1812 1855 1813 // ### optimi se all other replace method, by offering1856 // ### optimie all other replace method, by offering 1814 1857 // QByteArray::replace(const char *before, int blen, const char *after, int alen) 1815 1858 … … 2126 2169 return QByteArray(); // not enough memory 2127 2170 2128 qMemCopy(result.d->data, d->data, d->size);2171 py(result.d->data, d->data, d->size); 2129 2172 2130 2173 int sizeSoFar = d->size; … … 2133 2176 const int halfResultSize = resultSize >> 1; 2134 2177 while (sizeSoFar <= halfResultSize) { 2135 qMemCopy(end, result.d->data, sizeSoFar);2178 py(end, result.d->data, sizeSoFar); 2136 2179 end += sizeSoFar; 2137 2180 sizeSoFar <<= 1; 2138 2181 } 2139 qMemCopy(end, result.d->data, resultSize - sizeSoFar);2182 py(end, result.d->data, resultSize - sizeSoFar); 2140 2183 result.d->data[resultSize] = '\0'; 2141 2184 result.d->size = resultSize; … … 2660 2703 to the stream. 2661 2704 2662 \sa { Format of the QDataStream operators}2705 \sa {s} 2663 2706 */ 2664 2707 … … 2677 2720 reference to the stream. 2678 2721 2679 \sa { Format of the QDataStream operators}2722 \sa {s} 2680 2723 */ 2681 2724 … … 3793 3836 fail. 3794 3837 3795 \sa data(), constData()3838 \sa data(), constData() 3796 3839 */ 3797 3840 … … 3810 3853 *x->array = '\0'; 3811 3854 return QByteArray(x, 0, 0); 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3812 3886 } 3813 3887 … … 4207 4281 4208 4282 /*! 4209 \fn QByteArray& QByteArray::setRawData(const char *a, uint n)4210 4211 Use fromRawData() instead.4212 */4213 4214 /*!4215 4283 \fn void QByteArray::resetRawData(const char *data, uint n) 4216 4284
Note:
See TracChangeset
for help on using the changeset viewer.