Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
a8b3eb65
Commit
a8b3eb65
authored
Jan 03, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No, Insert() does not need to be recursive
parent
8d2e90de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
41 deletions
+21
-41
src/misc/variables.c
src/misc/variables.c
+21
-41
No files found.
src/misc/variables.c
View file @
a8b3eb65
...
...
@@ -154,8 +154,7 @@ time_ops = { CmpTime, DupDummy, FreeDummy, };
*****************************************************************************/
static
void
WaitUnused
(
vlc_object_t
*
,
variable_t
*
);
static
uint32_t
HashString
(
const
char
*
);
static
int
Insert
(
variable_t
**
,
int
,
const
char
*
);
static
int
InsertInner
(
variable_t
**
,
int
,
uint32_t
);
static
size_t
Insert
(
variable_t
**
,
size_t
,
const
char
*
);
static
int
Lookup
(
vlc_object_t
*
,
const
char
*
);
static
void
CheckValue
(
variable_t
*
,
vlc_value_t
*
);
...
...
@@ -1182,54 +1181,35 @@ static uint32_t HashString( const char *psz_string )
}
/*****************************************************************************
* Insert: find an empty slot to insert a new variable
*****************************************************************************
* We use a recursive inner function indexed on the hash. This function does
* nothing in the rare cases where a collision may occur, see Lookup()
* to see how we handle them.
* XXX: does this really need to be written recursively?
* Insert: find the slot where to insert a variable
*****************************************************************************/
static
int
Insert
(
variable_t
**
pp_vars
,
int
i_count
,
const
char
*
psz_name
)
{
if
(
i_count
==
0
)
{
return
0
;
}
return
InsertInner
(
pp_vars
,
i_count
,
HashString
(
psz_name
)
);
}
static
int
InsertInner
(
variable_t
**
pp_vars
,
int
i_count
,
uint32_t
i_hash
)
static
size_t
Insert
(
variable_t
**
pp_vars
,
size_t
n
,
const
char
*
psz_name
)
{
int
i_middle
;
size_t
offset
=
0
;
uint32_t
hash
=
HashString
(
psz_name
);
if
(
i_hash
<=
pp_vars
[
0
]
->
i_hash
)
{
if
(
n
==
0
)
return
0
;
}
if
(
i_hash
>=
pp_vars
[
i_count
-
1
]
->
i_hash
)
while
(
n
>
1
)
{
return
i_count
;
}
i_middle
=
i_count
/
2
;
/* We know that 0 < i_middle */
if
(
i_hash
<
pp_vars
[
i_middle
]
->
i_hash
)
{
return
InsertInner
(
pp_vars
,
i_middle
,
i_hash
);
}
size_t
middle
=
n
/
2
;
/* We know that i_middle + 1 < i_count */
if
(
i_hash
>
pp_vars
[
i_middle
+
1
]
->
i_hash
)
{
return
i_middle
+
1
+
InsertInner
(
pp_vars
+
i_middle
+
1
,
i_count
-
i_middle
-
1
,
i_hash
);
if
(
hash
<
pp_vars
[
middle
]
->
i_hash
)
{
n
=
middle
;
}
else
{
pp_vars
+=
middle
;
offset
+=
middle
;
n
-=
middle
;
}
}
return
i_middle
+
1
;
if
(
hash
>=
pp_vars
[
0
]
->
i_hash
)
offset
++
;
return
offset
;
}
static
int
u32cmp
(
const
void
*
key
,
const
void
*
data
)
...
...
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