Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wasm-watermarker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nagayama15
wasm-watermarker
Commits
45d6fae4
Verified
Commit
45d6fae4
authored
Oct 03, 2020
by
nagayama15
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: refactor
parent
14f6bdee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
Ordering-inl.hpp
lib/kyut/Ordering-inl.hpp
+13
-10
No files found.
lib/kyut/Ordering-inl.hpp
View file @
45d6fae4
...
...
@@ -22,14 +22,15 @@ namespace kyut {
assert
(
std
::
distance
(
begin
,
end
)
>=
0
);
assert
(
std
::
distance
(
begin
,
end
)
<=
std
::
ptrdiff_t
{
max_chunk_size
});
const
std
::
size_t
count
=
std
::
distance
(
begin
,
end
);
const
auto
bit_width
=
factorial_bit_width_table
[
count
];
std
::
uint64_t
watermark
=
r
.
read
(
bit_width
);
// Sort the chunk.
std
::
sort
(
begin
,
end
,
less
);
// Embed watermark.
const
std
::
size_t
count
=
std
::
distance
(
begin
,
end
);
const
std
::
size_t
bit_width
=
factorial_bit_width_table
[
count
];
std
::
uint64_t
watermark
=
r
.
read
(
bit_width
);
for
(
std
::
size_t
i
=
0
;
i
<
count
;
i
++
)
{
const
std
::
uint64_t
w
=
watermark
%
(
count
-
i
);
watermark
/=
(
count
-
i
);
...
...
@@ -74,11 +75,9 @@ namespace kyut {
assert
(
std
::
distance
(
begin
,
end
)
>=
0
);
assert
(
std
::
distance
(
begin
,
end
)
<=
std
::
ptrdiff_t
{
max_chunk_size
});
const
std
::
size_t
count
=
std
::
distance
(
begin
,
end
);
// Sort the chunk.
std
::
vector
<
RandomAccessIterator
>
chunk
{};
chunk
.
reserve
(
count
);
chunk
.
reserve
(
std
::
distance
(
begin
,
end
)
);
for
(
auto
it
=
begin
;
it
!=
end
;
it
++
)
{
chunk
.
emplace_back
(
it
);
...
...
@@ -88,11 +87,17 @@ namespace kyut {
return
less
(
*
a
,
*
b
);
});
const
auto
chunk_begin
=
std
::
begin
(
chunk
);
const
auto
chunk_end
=
std
::
end
(
chunk
);
const
std
::
size_t
count
=
std
::
distance
(
chunk_begin
,
chunk_end
);
const
std
::
size_t
bit_width
=
factorial_bit_width_table
[
count
];
// Extract watermark.
std
::
uint64_t
watermark
=
0
;
std
::
uint64_t
base
=
1
;
for
(
std
::
size_t
i
=
0
;
i
<
count
;
i
++
)
{
const
auto
it
=
std
::
begin
(
chunk
)
+
i
;
const
auto
it
=
chunk_begin
+
i
;
// Find the position of `begin + i`.
const
auto
found
=
std
::
find
(
it
,
std
::
end
(
chunk
),
begin
+
i
);
...
...
@@ -107,8 +112,6 @@ namespace kyut {
std
::
iter_swap
(
it
,
found
);
}
const
auto
bit_width
=
factorial_bit_width_table
[
count
];
assert
(
watermark
<
(
std
::
uint64_t
{
1
}
<<
bit_width
));
w
.
write
(
watermark
,
bit_width
);
...
...
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