Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
dc25448a
Commit
dc25448a
authored
Aug 08, 2015
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some adjustment to use new string hash function
parent
f76fb2fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
32 deletions
+3
-32
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-2
src/runtime/types.h
src/runtime/types.h
+1
-30
No files found.
src/runtime/builtin_modules/sys.cpp
View file @
dc25448a
...
...
@@ -39,6 +39,7 @@ BoxedDict* sys_modules_dict;
extern
"C"
{
// supposed to be exposed through sys.flags
int
Py_BytesWarningFlag
=
0
;
int
Py_HashRandomizationFlag
=
0
;
}
Box
*
sysExcInfo
()
{
...
...
src/runtime/objmodel.cpp
View file @
dc25448a
...
...
@@ -130,9 +130,8 @@ size_t PyHasher::operator()(Box* b) const {
ScopedStatTimer
_st
(
pyhasher_timer_counter
,
10
);
#endif
if
(
b
->
cls
==
str_cls
)
{
StringHash
<
char
>
H
;
auto
s
=
static_cast
<
BoxedString
*>
(
b
);
return
H
(
s
->
data
(),
s
->
size
()
);
return
strHashUnboxed
(
s
);
}
return
hashUnboxed
(
b
);
...
...
src/runtime/types.h
View file @
dc25448a
...
...
@@ -430,36 +430,7 @@ private:
friend
void
setupRuntime
();
};
template
<
typename
T
>
struct
StringHash
{
size_t
operator
()(
const
T
*
str
)
{
size_t
hash
=
5381
;
T
c
;
while
((
c
=
*
str
++
))
hash
=
((
hash
<<
5
)
+
hash
)
+
c
;
/* hash * 33 + c */
return
hash
;
}
size_t
operator
()(
const
T
*
str
,
int
len
)
{
size_t
hash
=
5381
;
T
c
;
while
(
--
len
>=
0
)
{
c
=
*
str
++
;
hash
=
((
hash
<<
5
)
+
hash
)
+
c
;
/* hash * 33 + c */
}
return
hash
;
}
};
template
<
>
struct
StringHash
<
std
::
string
>
{
size_t
operator
()(
const
std
::
string
&
str
)
{
StringHash
<
char
>
H
;
return
H
(
&
str
[
0
],
str
.
size
());
}
};
extern
"C"
size_t
strHashUnboxed
(
BoxedString
*
self
);
class
BoxedInstanceMethod
:
public
Box
{
public:
...
...
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