Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
http-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cython-plus
http-server
Commits
1899ec28
Commit
1899ec28
authored
Nov 09, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement string __hash__
parent
518f6ec7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
src/stdlib/_string.pxd
src/stdlib/_string.pxd
+5
-0
src/stdlib/string.pxd
src/stdlib/string.pxd
+4
-1
No files found.
src/stdlib/_string.pxd
View file @
1899ec28
...
...
@@ -142,3 +142,8 @@ cdef extern from "<string_view>" namespace "std" nogil:
bint
operator
>=
(
const
string_view
&
)
bint
operator
>=
(
const
char
*
)
cdef
cppclass
hash_string_view
"std::hash<std::string_view>"
:
hash_string_view
()
size_t
operator
()
(
const
string_view
&
)
src/stdlib/string.pxd
View file @
1899ec28
from
stdlib._string
cimport
string_view
from
stdlib._string
cimport
string_view
,
hash_string_view
from
libc.string
cimport
strlen
,
strncpy
from
libc.stdlib
cimport
malloc
,
free
...
...
@@ -23,6 +23,9 @@ cdef cypclass Str:
bint
__eq__
(
self
,
Str
other
):
return
self
.
_s
==
other
.
_s
size_t
__hash__
(
self
):
return
hash_string_view
()(
self
.
_s
)
char
__getitem__
(
self
,
int
index
)
except
0
:
cdef
int
end
=
self
.
_s
.
size
()
cdef
int
idx
=
index
...
...
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