Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
60d8b188
Kaydet (Commit)
60d8b188
authored
May 27, 2006
tarafından
Fredrik Lundh
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
needforspeed: stringlib refactoring: changed find_obj to find_slice,
to enable use from stringobject
üst
c2d29c5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
36 deletions
+69
-36
find.h
Objects/stringlib/find.h
+39
-18
unicodeobject.c
Objects/unicodeobject.c
+30
-18
No files found.
Objects/stringlib/find.h
Dosyayı görüntüle @
60d8b188
...
...
@@ -48,18 +48,49 @@ stringlib_rfind(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
return
pos
;
}
#ifdef STRINGLIB_STR
Py_LOCAL_INLINE
(
Py_ssize_t
)
stringlib_find_obj
(
PyObject
*
str
,
PyObject
*
sub
,
Py_ssize_t
start
,
Py_ssize_t
end
)
stringlib_find_slice
(
const
STRINGLIB_CHAR
*
str
,
Py_ssize_t
str_len
,
const
STRINGLIB_CHAR
*
sub
,
Py_ssize_t
sub_len
,
Py_ssize_t
start
,
Py_ssize_t
end
)
{
if
(
start
<
0
)
start
+=
str_len
;
if
(
start
<
0
)
start
=
0
;
if
(
end
>
str_len
)
end
=
str_len
;
if
(
end
<
0
)
end
+=
str_len
;
if
(
end
<
0
)
end
=
0
;
return
stringlib_find
(
STRINGLIB_STR
(
str
)
+
start
,
end
-
start
,
STRINGLIB_STR
(
sub
),
STRINGLIB_LEN
(
sub
)
,
start
str
+
start
,
end
-
start
,
sub
,
sub_len
,
start
);
}
Py_LOCAL_INLINE
(
Py_ssize_t
)
stringlib_rfind_slice
(
const
STRINGLIB_CHAR
*
str
,
Py_ssize_t
str_len
,
const
STRINGLIB_CHAR
*
sub
,
Py_ssize_t
sub_len
,
Py_ssize_t
start
,
Py_ssize_t
end
)
{
if
(
start
<
0
)
start
+=
str_len
;
if
(
start
<
0
)
start
=
0
;
if
(
end
>
str_len
)
end
=
str_len
;
if
(
end
<
0
)
end
+=
str_len
;
if
(
end
<
0
)
end
=
0
;
return
stringlib_rfind
(
str
+
start
,
end
-
start
,
sub
,
sub_len
,
start
);
}
#ifdef STRINGLIB_STR
Py_LOCAL_INLINE
(
int
)
stringlib_contains_obj
(
PyObject
*
str
,
PyObject
*
sub
)
{
...
...
@@ -69,19 +100,9 @@ stringlib_contains_obj(PyObject* str, PyObject* sub)
)
!=
-
1
;
}
Py_LOCAL_INLINE
(
Py_ssize_t
)
stringlib_rfind_obj
(
PyObject
*
str
,
PyObject
*
sub
,
Py_ssize_t
start
,
Py_ssize_t
end
)
{
return
stringlib_rfind
(
STRINGLIB_STR
(
str
)
+
start
,
end
-
start
,
STRINGLIB_STR
(
sub
),
STRINGLIB_LEN
(
sub
),
start
);
}
#endif
#endif
/* STRINGLIB_STR */
#endif
#endif
/* STRINGLIB_FIND_H */
/*
Local variables:
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
60d8b188
...
...
@@ -3936,12 +3936,18 @@ Py_ssize_t PyUnicode_Find(PyObject *str,
return
-
2
;
}
FIX_START_END
((
PyUnicodeObject
*
)
str
);
if
(
direction
>
0
)
result
=
stringlib_find_obj
(
str
,
sub
,
start
,
end
);
result
=
stringlib_find_slice
(
PyUnicode_AS_UNICODE
(
str
),
PyUnicode_GET_SIZE
(
str
),
PyUnicode_AS_UNICODE
(
sub
),
PyUnicode_GET_SIZE
(
sub
),
start
,
end
);
else
result
=
stringlib_rfind_obj
(
str
,
sub
,
start
,
end
);
result
=
stringlib_rfind_slice
(
PyUnicode_AS_UNICODE
(
str
),
PyUnicode_GET_SIZE
(
str
),
PyUnicode_AS_UNICODE
(
sub
),
PyUnicode_GET_SIZE
(
sub
),
start
,
end
);
Py_DECREF
(
str
);
Py_DECREF
(
sub
);
...
...
@@ -5284,14 +5290,15 @@ unicode_find(PyUnicodeObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"O|O&O&:find"
,
&
substring
,
_PyEval_SliceIndex
,
&
start
,
_PyEval_SliceIndex
,
&
end
))
return
NULL
;
substring
=
PyUnicode_FromObject
(
substring
);
if
(
!
substring
)
return
NULL
;
FIX_START_END
(
self
);
result
=
stringlib_find_obj
((
PyObject
*
)
self
,
substring
,
start
,
end
);
result
=
stringlib_find_slice
(
PyUnicode_AS_UNICODE
(
self
),
PyUnicode_GET_SIZE
(
self
),
PyUnicode_AS_UNICODE
(
substring
),
PyUnicode_GET_SIZE
(
substring
),
start
,
end
);
Py_DECREF
(
substring
);
...
...
@@ -5352,14 +5359,15 @@ unicode_index(PyUnicodeObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"O|O&O&:index"
,
&
substring
,
_PyEval_SliceIndex
,
&
start
,
_PyEval_SliceIndex
,
&
end
))
return
NULL
;
substring
=
PyUnicode_FromObject
(
substring
);
if
(
!
substring
)
return
NULL
;
FIX_START_END
(
self
);
result
=
stringlib_find_obj
((
PyObject
*
)
self
,
substring
,
start
,
end
);
result
=
stringlib_find_slice
(
PyUnicode_AS_UNICODE
(
self
),
PyUnicode_GET_SIZE
(
self
),
PyUnicode_AS_UNICODE
(
substring
),
PyUnicode_GET_SIZE
(
substring
),
start
,
end
);
Py_DECREF
(
substring
);
...
...
@@ -6027,9 +6035,11 @@ unicode_rfind(PyUnicodeObject *self, PyObject *args)
if
(
!
substring
)
return
NULL
;
FIX_START_END
(
self
);
result
=
stringlib_rfind_obj
((
PyObject
*
)
self
,
substring
,
start
,
end
);
result
=
stringlib_rfind_slice
(
PyUnicode_AS_UNICODE
(
self
),
PyUnicode_GET_SIZE
(
self
),
PyUnicode_AS_UNICODE
(
substring
),
PyUnicode_GET_SIZE
(
substring
),
start
,
end
);
Py_DECREF
(
substring
);
...
...
@@ -6056,9 +6066,11 @@ unicode_rindex(PyUnicodeObject *self, PyObject *args)
if
(
!
substring
)
return
NULL
;
FIX_START_END
(
self
);
result
=
stringlib_rfind_obj
((
PyObject
*
)
self
,
substring
,
start
,
end
);
result
=
stringlib_rfind_slice
(
PyUnicode_AS_UNICODE
(
self
),
PyUnicode_GET_SIZE
(
self
),
PyUnicode_AS_UNICODE
(
substring
),
PyUnicode_GET_SIZE
(
substring
),
start
,
end
);
Py_DECREF
(
substring
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment