Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
9a41a4e9
Commit
9a41a4e9
authored
Dec 09, 2006
by
Eric Pouech
Committed by
Alexandre Julliard
Dec 11, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Sparse array speed up.
parent
5c060934
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
9 deletions
+42
-9
storage.c
dlls/dbghelp/storage.c
+42
-9
No files found.
dlls/dbghelp/storage.c
View file @
9a41a4e9
...
...
@@ -244,22 +244,55 @@ void sparse_array_init(struct sparse_array* sa, unsigned elt_sz, unsigned bucket
}
/******************************************************************
* spare_array_lookup
* spar
s
e_array_lookup
*
* Returns the first index which key is >= at passed key
*/
static
struct
key2index
*
spare_array_lookup
(
const
struct
sparse_array
*
sa
,
unsigned
long
key
,
unsigned
*
idx
)
static
struct
key2index
*
spar
s
e_array_lookup
(
const
struct
sparse_array
*
sa
,
unsigned
long
key
,
unsigned
*
idx
)
{
struct
key2index
*
pk2i
;
unsigned
low
,
high
;
/* FIXME: should use bsearch here */
for
(
*
idx
=
0
;
*
idx
<
sa
->
elements
.
num_elts
;
(
*
idx
)
++
)
if
(
!
sa
->
elements
.
num_elts
)
{
*
idx
=
0
;
return
NULL
;
}
high
=
sa
->
elements
.
num_elts
;
pk2i
=
vector_at
(
&
sa
->
key2index
,
high
-
1
);
if
(
pk2i
->
key
<
key
)
{
*
idx
=
high
;
return
NULL
;
}
if
(
pk2i
->
key
==
key
)
{
*
idx
=
high
-
1
;
return
pk2i
;
}
low
=
0
;
pk2i
=
vector_at
(
&
sa
->
key2index
,
low
);
if
(
pk2i
->
key
>=
key
)
{
*
idx
=
0
;
return
pk2i
;
}
/* now we have: sa(lowest key) < key < sa(highest key) */
while
(
low
<
high
)
{
*
idx
=
(
low
+
high
)
/
2
;
pk2i
=
vector_at
(
&
sa
->
key2index
,
*
idx
);
if
(
pk2i
&&
pk2i
->
key
>=
key
)
return
pk2i
;
if
(
pk2i
->
key
>
key
)
high
=
*
idx
;
else
if
(
pk2i
->
key
<
key
)
low
=
*
idx
+
1
;
else
return
pk2i
;
}
return
NULL
;
/* binary search could return exact item, we search for highest one
* below the key
*/
if
(
pk2i
->
key
<
key
)
pk2i
=
vector_at
(
&
sa
->
key2index
,
++
(
*
idx
));
return
pk2i
;
}
void
*
sparse_array_find
(
const
struct
sparse_array
*
sa
,
unsigned
long
key
)
...
...
@@ -267,7 +300,7 @@ void* sparse_array_find(const struct sparse_array* sa, unsigned long key)
unsigned
idx
;
struct
key2index
*
pk2i
;
if
((
pk2i
=
spare_array_lookup
(
sa
,
key
,
&
idx
))
&&
pk2i
->
key
==
key
)
if
((
pk2i
=
spar
s
e_array_lookup
(
sa
,
key
,
&
idx
))
&&
pk2i
->
key
==
key
)
return
vector_at
(
&
sa
->
elements
,
pk2i
->
index
);
return
NULL
;
}
...
...
@@ -279,7 +312,7 @@ void* sparse_array_add(struct sparse_array* sa, unsigned long key,
struct
key2index
*
pk2i
;
struct
key2index
*
to
;
pk2i
=
spare_array_lookup
(
sa
,
key
,
&
idx
);
pk2i
=
spar
s
e_array_lookup
(
sa
,
key
,
&
idx
);
if
(
pk2i
&&
pk2i
->
key
==
key
)
{
FIXME
(
"re adding an existing key
\n
"
);
...
...
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