Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Klepl Jiří
asgn
Commits
da28db02
Commit
da28db02
authored
Apr 08, 2020
by
s_kleplj
Browse files
spaces are added by children, shorter hashing
parent
2fcd607c
Changes
2
Show whitespace changes
Inline
Side-by-side
sol/macrosol.cpp
View file @
da28db02
...
...
@@ -95,10 +95,7 @@ bool macroprocessor_impl::process(
for
(
std
::
size_t
i
=
0
;
i
<
parsed
.
size
();
++
i
)
{
if
(
found
[
i
]
!=
nullptr
)
{
if
(
found
[
i
]
->
length
>
0
)
{
found
[
i
]
->
append_to
(
output
);
output
+=
' '
;
}
}
else
{
output
+=
parsed
[
i
];
output
+=
' '
;
...
...
sol/macrosol.hpp
View file @
da28db02
...
...
@@ -31,6 +31,20 @@ struct policy_avx512 {
};
#endif
template
<
std
::
size_t
strength
>
class
view_hasher
{
public:
std
::
size_t
operator
()(
const
std
::
string_view
&
a
)
const
{
std
::
size_t
ret
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
strength
;
++
i
)
{
ret
*=
26
;
ret
+=
i
<
a
.
size
()
?
(
a
[
i
]
|
32
)
-
'a'
:
0
;
}
return
ret
;
}
};
class
macroprocessor_impl
{
public:
bool
process
(
const
std
::
string
&
s
,
std
::
string
&
output
);
...
...
@@ -56,15 +70,13 @@ class macroprocessor_impl {
if
(
value_
.
size
()
==
0
&&
length
>
0
)
{
output
+=
name_
;
output
+=
' '
;
}
else
{
for
(
word
*
w
:
value_
)
{
if
(
w
->
length
>
0
)
{
w
->
append_to
(
output
);
output
+=
' '
;
}
}
output
.
pop_back
();
}
}
...
...
@@ -91,7 +103,7 @@ class macroprocessor_impl {
std
::
size_t
length
;
};
std
::
unordered_map
<
std
::
string_view
,
word
>
words_
;
std
::
unordered_map
<
std
::
string_view
,
word
,
view_hasher
<
3
>
>
words_
;
std
::
vector
<
std
::
string_view
>
parsed
;
std
::
vector
<
const
word
*>
found
;
};
...
...
Write
Preview
Supports
Markdown
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