Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: Objects/bytearrayobject.c

Issue 26574: replace_interleave can be optimized for single character byte strings
Left Patch Set: Created 3 years, 11 months ago
Right Patch Set: Created 3 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Misc/ACKS ('k') | Objects/bytesobject.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* PyByteArray (bytearray) implementation */ 1 /* PyByteArray (bytearray) implementation */
2 2
3 #define PY_SSIZE_T_CLEAN 3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h" 4 #include "Python.h"
5 #include "structmember.h" 5 #include "structmember.h"
6 #include "bytes_methods.h" 6 #include "bytes_methods.h"
7 #include "bytesobject.h" 7 #include "bytesobject.h"
8 #include "pystrhex.h" 8 #include "pystrhex.h"
9 9
10 /*[clinic input] 10 /*[clinic input]
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 /* Lay the first one down (guaranteed this will occur) */ 1709 /* Lay the first one down (guaranteed this will occur) */
1710 Py_MEMCPY(result_s, to_s, to_len); 1710 Py_MEMCPY(result_s, to_s, to_len);
1711 result_s += to_len; 1711 result_s += to_len;
1712 count -= 1; 1712 count -= 1;
1713 1713
1714 for (i = 0; i < count; i++) { 1714 for (i = 0; i < count; i++) {
1715 *result_s++ = *self_s++; 1715 *result_s++ = *self_s++;
1716 Py_MEMCPY(result_s, to_s, to_len); 1716 Py_MEMCPY(result_s, to_s, to_len);
1717 result_s += to_len; 1717 result_s += to_len;
1718 } 1718 }
1719 1719 }
haypo 2016/03/17 00:45:05 I don't think that this newline is needed.
1720 } else { 1720 else {
haypo 2016/03/17 00:45:05 PEP 7: need to rewrite this line as: } else {
1721 result_s[0] = to_s[0]; 1721 result_s[0] = to_s[0];
1722 result_s += to_len; 1722 result_s += to_len;
1723 count -= 1; 1723 count -= 1;
1724 for (i = 0; i < count; i++) { 1724 for (i = 0; i < count; i++) {
1725 *result_s++ = *self_s++; 1725 *result_s++ = *self_s++;
1726 result_s[0] = to_s[0]; 1726 result_s[0] = to_s[0];
1727 result_s += to_len; 1727 result_s += to_len;
1728 } 1728 }
1729 } 1729 }
1730
1730 /* Copy the rest of the original string */ 1731 /* Copy the rest of the original string */
1731 Py_MEMCPY(result_s, self_s, self_len-i); 1732 Py_MEMCPY(result_s, self_s, self_len-i);
1733
1732 return result; 1734 return result;
1733 } 1735 }
1734 1736
1735 /* Special case for deleting a single character */ 1737 /* Special case for deleting a single character */
1736 /* len(self)>=1, len(from)==1, to="", maxcount>=1 */ 1738 /* len(self)>=1, len(from)==1, to="", maxcount>=1 */
1737 Py_LOCAL(PyByteArrayObject *) 1739 Py_LOCAL(PyByteArrayObject *)
1738 replace_delete_single_character(PyByteArrayObject *self, 1740 replace_delete_single_character(PyByteArrayObject *self,
1739 char from_c, Py_ssize_t maxcount) 1741 char from_c, Py_ssize_t maxcount)
1740 { 1742 {
1741 char *self_s, *result_s; 1743 char *self_s, *result_s;
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 } 3229 }
3228 it = PyObject_GC_New(bytesiterobject, &PyByteArrayIter_Type); 3230 it = PyObject_GC_New(bytesiterobject, &PyByteArrayIter_Type);
3229 if (it == NULL) 3231 if (it == NULL)
3230 return NULL; 3232 return NULL;
3231 it->it_index = 0; 3233 it->it_index = 0;
3232 Py_INCREF(seq); 3234 Py_INCREF(seq);
3233 it->it_seq = (PyByteArrayObject *)seq; 3235 it->it_seq = (PyByteArrayObject *)seq;
3234 _PyObject_GC_TRACK(it); 3236 _PyObject_GC_TRACK(it);
3235 return (PyObject *)it; 3237 return (PyObject *)it;
3236 } 3238 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+