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
3a65d87e
Kaydet (Commit)
3a65d87e
authored
May 26, 2006
tarafından
Fredrik Lundh
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
needforspeed: remove remaining USE_FAST macros; if fastsearch was
broken, someone would have noticed by now ;-)
üst
c2032fb8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
67 deletions
+2
-67
stringobject.c
Objects/stringobject.c
+2
-67
No files found.
Objects/stringobject.c
Dosyayı görüntüle @
3a65d87e
...
@@ -767,10 +767,6 @@ PyString_AsStringAndSize(register PyObject *obj,
...
@@ -767,10 +767,6 @@ PyString_AsStringAndSize(register PyObject *obj,
/* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
/* stringlib components */
/* stringlib components */
#define USE_FAST
#ifdef USE_FAST
#define STRINGLIB_CHAR char
#define STRINGLIB_CHAR char
#define STRINGLIB_NEW PyString_FromStringAndSize
#define STRINGLIB_NEW PyString_FromStringAndSize
#define STRINGLIB_EMPTY nullstring
#define STRINGLIB_EMPTY nullstring
...
@@ -778,8 +774,6 @@ PyString_AsStringAndSize(register PyObject *obj,
...
@@ -778,8 +774,6 @@ PyString_AsStringAndSize(register PyObject *obj,
#include "stringlib/fastsearch.h"
#include "stringlib/fastsearch.h"
#include "stringlib/partition.h"
#include "stringlib/partition.h"
#endif
/* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
/* Methods */
/* Methods */
...
@@ -1054,13 +1048,7 @@ string_contains(PyObject *a, PyObject *el)
...
@@ -1054,13 +1048,7 @@ string_contains(PyObject *a, PyObject *el)
char
*
s
=
PyString_AS_STRING
(
a
);
char
*
s
=
PyString_AS_STRING
(
a
);
const
char
*
sub
=
PyString_AS_STRING
(
el
);
const
char
*
sub
=
PyString_AS_STRING
(
el
);
Py_ssize_t
len_sub
=
PyString_GET_SIZE
(
el
);
Py_ssize_t
len_sub
=
PyString_GET_SIZE
(
el
);
#ifdef USE_FAST
Py_ssize_t
pos
;
Py_ssize_t
pos
;
#else
char
*
last
;
Py_ssize_t
shortsub
;
char
firstchar
,
lastchar
;
#endif
if
(
!
PyString_CheckExact
(
el
))
{
if
(
!
PyString_CheckExact
(
el
))
{
#ifdef Py_USING_UNICODE
#ifdef Py_USING_UNICODE
...
@@ -1077,35 +1065,12 @@ string_contains(PyObject *a, PyObject *el)
...
@@ -1077,35 +1065,12 @@ string_contains(PyObject *a, PyObject *el)
if
(
len_sub
==
0
)
if
(
len_sub
==
0
)
return
1
;
return
1
;
#ifdef USE_FAST
pos
=
fastsearch
(
pos
=
fastsearch
(
s
,
PyString_GET_SIZE
(
a
),
s
,
PyString_GET_SIZE
(
a
),
sub
,
len_sub
,
FAST_SEARCH
sub
,
len_sub
,
FAST_SEARCH
);
);
return
(
pos
!=
-
1
);
return
(
pos
!=
-
1
);
#else
/* last points to one char beyond the start of the rightmost
substring. When s<last, there is still room for a possible match
and s[0] through s[len_sub-1] will be in bounds.
shortsub is len_sub minus the last character which is checked
separately just before the memcmp(). That check helps prevent
false starts and saves the setup time for memcmp().
*/
firstchar
=
sub
[
0
];
shortsub
=
len_sub
-
1
;
lastchar
=
sub
[
shortsub
];
last
=
s
+
PyString_GET_SIZE
(
a
)
-
len_sub
+
1
;
while
(
s
<
last
)
{
s
=
(
char
*
)
memchr
(
s
,
firstchar
,
last
-
s
);
if
(
s
==
NULL
)
return
0
;
assert
(
s
<
last
);
if
(
s
[
shortsub
]
==
lastchar
&&
memcmp
(
s
,
sub
,
shortsub
)
==
0
)
return
1
;
s
++
;
}
#endif
return
0
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1854,7 +1819,6 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir)
...
@@ -1854,7 +1819,6 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir)
string_adjust_indices
(
&
i
,
&
last
,
len
);
string_adjust_indices
(
&
i
,
&
last
,
len
);
#ifdef USE_FAST
if
(
n
==
0
)
if
(
n
==
0
)
return
(
dir
>
0
)
?
i
:
last
;
return
(
dir
>
0
)
?
i
:
last
;
if
(
dir
>
0
)
{
if
(
dir
>
0
)
{
...
@@ -1863,17 +1827,7 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir)
...
@@ -1863,17 +1827,7 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir)
if
(
pos
<
0
)
if
(
pos
<
0
)
return
pos
;
return
pos
;
return
pos
+
i
;
return
pos
+
i
;
}
}
else
{
#endif
if
(
dir
>
0
)
{
if
(
n
==
0
&&
i
<=
last
)
return
(
long
)
i
;
last
-=
n
;
for
(;
i
<=
last
;
++
i
)
if
(
s
[
i
]
==
sub
[
0
]
&&
memcmp
(
&
s
[
i
],
sub
,
n
)
==
0
)
return
(
long
)
i
;
}
else
{
Py_ssize_t
j
;
Py_ssize_t
j
;
if
(
n
==
0
&&
i
<=
last
)
if
(
n
==
0
&&
i
<=
last
)
...
@@ -2299,28 +2253,9 @@ string_count(PyStringObject *self, PyObject *args)
...
@@ -2299,28 +2253,9 @@ string_count(PyStringObject *self, PyObject *args)
if
(
n
==
0
)
if
(
n
==
0
)
return
PyInt_FromSsize_t
(
m
-
i
);
return
PyInt_FromSsize_t
(
m
-
i
);
#ifdef USE_FAST
r
=
fastsearch
(
s
+
i
,
last
-
i
,
sub
,
n
,
FAST_COUNT
);
r
=
fastsearch
(
s
+
i
,
last
-
i
,
sub
,
n
,
FAST_COUNT
);
if
(
r
<
0
)
if
(
r
<
0
)
r
=
0
;
/* no match */
r
=
0
;
/* no match */
#else
r
=
0
;
while
(
i
<
m
)
{
const
char
*
t
;
if
(
!
memcmp
(
s
+
i
,
sub
,
n
))
{
r
++
;
i
+=
n
;
}
else
{
i
++
;
}
if
(
i
>=
m
)
break
;
t
=
(
const
char
*
)
memchr
(
s
+
i
,
sub
[
0
],
m
-
i
);
if
(
t
==
NULL
)
break
;
i
=
t
-
s
;
}
#endif
return
PyInt_FromSsize_t
(
r
);
return
PyInt_FromSsize_t
(
r
);
}
}
...
...
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