Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
748b3dd7
Commit
748b3dd7
authored
2 years ago
by
Valentin Perrelle
Browse files
Options
Downloads
Patches
Plain Diff
[Kernel] FCHashtbl: do not convert hash table to map/set for sorting
parent
a5fda43a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libraries/stdlib/FCHashtbl.ml
+8
-19
8 additions, 19 deletions
src/libraries/stdlib/FCHashtbl.ml
with
8 additions
and
19 deletions
src/libraries/stdlib/FCHashtbl.ml
+
8
−
19
View file @
748b3dd7
...
...
@@ -50,30 +50,19 @@ module Make(H: Hashtbl.HashedType) : S with type key = H.t = struct
include
Hashtbl
.
Make
(
H
)
let
bindings_sorted
?
(
cmp
=
Stdlib
.
compare
)
h
=
to_seq
h
|>
List
.
of_seq
|>
List
.
fast_sort
(
fun
(
k1
,_
)
(
k2
,_
)
->
cmp
k1
k2
)
let
fold_sorted
?
(
cmp
=
Stdlib
.
compare
)
f
h
acc
=
let
module
Aux
=
struct
type
t
=
key
let
compare
=
cmp
end
in
let
module
M
=
Map
.
Make
(
Aux
)
in
let
add
k
v
m
=
try
let
l
=
v
::
M
.
find
k
m
in
M
.
add
k
l
m
with
Not_found
->
M
.
add
k
[
v
]
m
in
let
map
=
fold
add
h
M
.
empty
in
let
fold_k
k
l
acc
=
List
.
fold_left
(
fun
acc
v
->
f
k
v
acc
)
acc
(
List
.
rev
l
)
in
M
.
fold
fold_k
map
acc
let
l
=
bindings_sorted
~
cmp
h
in
List
.
fold_left
(
fun
acc
(
k
,
v
)
->
f
k
v
acc
)
acc
l
let
iter_sorted
?
cmp
f
h
=
fold_sorted
?
cmp
(
fun
k
v
()
->
f
k
v
)
h
()
let
fold_sorted_by_entry
(
type
value
)
~
cmp
f
h
acc
=
let
module
Aux
=
struct
type
t
=
(
key
*
value
)
let
compare
=
cmp
end
in
let
module
S
=
Set
.
Make
(
Aux
)
in
let
add
k
v
s
=
S
.
add
(
k
,
v
)
s
in
let
set
=
fold
add
h
S
.
empty
in
S
.
fold
(
fun
(
k
,
v
)
->
f
k
v
)
set
acc
let
fold_sorted_by_entry
~
cmp
f
h
acc
=
let
l
=
to_seq
h
|>
List
.
of_seq
|>
List
.
fast_sort
cmp
in
List
.
fold_left
(
fun
acc
(
k
,
v
)
->
f
k
v
acc
)
acc
l
let
iter_sorted_by_entry
~
cmp
f
h
=
fold_sorted_by_entry
~
cmp
(
fun
k
v
()
->
f
k
v
)
h
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment