Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
5d3f3e0d
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5d3f3e0d
编写于
12月 07, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make text lookup use a simple linked lists rather than an unnecessary array of pointers
上级
9b882c09
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
31 deletion
+29
-31
libobs/obs-source.c
libobs/obs-source.c
+1
-1
libobs/util/text-lookup.c
libobs/util/text-lookup.c
+28
-30
未找到文件。
libobs/obs-source.c
浏览文件 @
5d3f3e0d
...
...
@@ -799,7 +799,7 @@ void obs_source_output_audio(obs_source_t source,
pthread_mutex_unlock
(
&
source
->
filter_mutex
);
}
/*
/*
* Ensures that cached frames are displayed on time. If multiple frames
* were cached between renders, then releases the unnecessary frames and uses
* the frame with the closest timing.
...
...
libobs/util/text-lookup.c
浏览文件 @
5d3f3e0d
...
...
@@ -22,7 +22,6 @@
******************************************************************************/
#include "dstr.h"
#include "darray.h"
#include "text-lookup.h"
#include "lexer.h"
#include "platform.h"
...
...
@@ -44,37 +43,42 @@ static inline void text_leaf_destroy(struct text_leaf *leaf)
struct
text_node
{
struct
dstr
str
;
struct
darray
subnodes
;
/* struct text_node * */
struct
text_node
*
first_subnode
;
struct
text_leaf
*
leaf
;
struct
text_node
*
next
;
};
static
void
text_node_destroy
(
struct
text_node
*
node
)
{
struct
text_node
**
subnodes
;
size_t
i
;
struct
text_node
*
subnode
;
if
(
!
node
)
return
;
subnodes
=
node
->
subnodes
.
array
;
subnode
=
node
->
first_subnode
;
while
(
subnode
)
{
struct
text_node
*
destroy_node
=
subnode
;
subnode
=
subnode
->
next
;
text_node_destroy
(
destroy_node
);
}
dstr_free
(
&
node
->
str
);
for
(
i
=
0
;
i
<
node
->
subnodes
.
num
;
i
++
)
text_node_destroy
(
subnodes
[
i
]);
if
(
node
->
leaf
)
text_leaf_destroy
(
node
->
leaf
);
darray_free
(
&
node
->
subnodes
);
bfree
(
node
);
}
static
struct
text_node
*
text_node_bychar
(
struct
text_node
*
node
,
char
ch
)
{
size_t
i
;
struct
text_node
**
subnodes
=
node
->
subnodes
.
array
;
struct
text_node
*
subnode
=
node
->
first_subnode
;
while
(
subnode
)
{
if
(
!
dstr_isempty
(
&
subnode
->
str
)
&&
subnode
->
str
.
array
[
0
]
==
ch
)
return
subnode
;
for
(
i
=
0
;
i
<
node
->
subnodes
.
num
;
i
++
)
{
struct
text_node
*
child
=
subnodes
[
i
];
if
(
!
dstr_isempty
(
&
child
->
str
)
&&
child
->
str
.
array
[
0
]
==
ch
)
return
child
;
subnode
=
subnode
->
next
;
}
return
NULL
;
...
...
@@ -83,25 +87,18 @@ static struct text_node *text_node_bychar(struct text_node *node, char ch)
static
struct
text_node
*
text_node_byname
(
struct
text_node
*
node
,
const
char
*
name
)
{
size_t
i
;
struct
text_node
**
subnodes
=
node
->
subnodes
.
array
;
struct
text_node
*
subnode
=
node
->
first_subnode
;
for
(
i
=
0
;
i
<
node
->
subnodes
.
num
;
i
++
)
{
struct
text_node
*
child
=
subnodes
[
i
];
if
(
astrcmpi_n
(
child
->
str
.
array
,
name
,
child
->
str
.
len
)
==
0
)
return
child
;
while
(
subnode
)
{
if
(
astrcmpi_n
(
subnode
->
str
.
array
,
name
,
subnode
->
str
.
len
)
==
0
)
return
subnode
;
subnode
=
subnode
->
next
;
}
return
NULL
;
}
static
inline
void
text_node_removesubnode
(
struct
text_node
*
node
,
struct
text_node
*
child
,
size_t
idx
)
{
darray_erase
(
sizeof
(
struct
text_node
*
),
&
node
->
subnodes
,
idx
);
text_node_destroy
(
child
);
}
/* ------------------------------------------------------------------------- */
struct
text_lookup
{
...
...
@@ -118,7 +115,8 @@ static void lookup_createsubnode(const char *lookup_val,
new
->
leaf
=
leaf
;
dstr_copy
(
&
new
->
str
,
lookup_val
);
darray_push_back
(
sizeof
(
struct
text_node
*
),
&
node
->
subnodes
,
&
new
);
new
->
next
=
node
->
first_subnode
;
node
->
first_subnode
=
new
;
}
static
void
lookup_splitnode
(
const
char
*
lookup_val
,
size_t
len
,
...
...
@@ -129,10 +127,10 @@ static void lookup_splitnode(const char *lookup_val, size_t len,
dstr_copy
(
&
split
->
str
,
node
->
str
.
array
+
len
);
split
->
leaf
=
node
->
leaf
;
darray_move
(
&
split
->
subnodes
,
&
node
->
subnodes
);
split
->
first_subnode
=
node
->
first_subnode
;
node
->
first_subnode
=
split
;
dstr_resize
(
&
node
->
str
,
len
);
darray_push_back
(
sizeof
(
struct
text_node
),
&
node
->
subnodes
,
&
split
);
if
(
lookup_val
[
len
]
!=
0
)
{
node
->
leaf
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录