Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
3248556f
Commit
3248556f
authored
3 years ago
by
MascaraSnake
Browse files
Options
Downloads
Patches
Plain Diff
Speed up taglist creation
parent
5149699d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1702
Speed up taglist creation
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/taglist.c
+35
-3
35 additions, 3 deletions
src/taglist.c
src/taglist.h
+1
-0
1 addition, 0 deletions
src/taglist.h
with
36 additions
and
3 deletions
src/taglist.c
+
35
−
3
View file @
3248556f
...
@@ -191,6 +191,38 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id)
...
@@ -191,6 +191,38 @@ void Taggroup_Add (taggroup_t *garray[], const mtag_t tag, size_t id)
group
->
elements
[
i
]
=
id
;
group
->
elements
[
i
]
=
id
;
}
}
static
void
Taggroup_Add_Init
(
taggroup_t
*
garray
[],
const
mtag_t
tag
,
size_t
id
)
{
taggroup_t
*
group
;
if
(
tag
==
MTAG_GLOBAL
)
return
;
group
=
garray
[(
UINT16
)
tag
];
if
(
!
in_bit_array
(
tags_available
,
tag
))
{
num_tags
++
;
set_bit_array
(
tags_available
,
tag
);
}
// Create group if empty.
if
(
!
group
)
group
=
garray
[(
UINT16
)
tag
]
=
Z_Calloc
(
sizeof
(
taggroup_t
),
PU_LEVEL
,
NULL
);
else
if
(
group
->
elements
[
group
->
count
-
1
]
==
id
)
return
;
// Don't add duplicates
group
->
count
++
;
if
(
group
->
count
>
group
->
capacity
)
{
group
->
capacity
=
2
*
group
->
count
;
group
->
elements
=
Z_Realloc
(
group
->
elements
,
group
->
capacity
*
sizeof
(
size_t
),
PU_LEVEL
,
NULL
);
}
group
->
elements
[
group
->
count
-
1
]
=
id
;
}
static
size_t
total_elements_with_tag
(
const
mtag_t
tag
)
static
size_t
total_elements_with_tag
(
const
mtag_t
tag
)
{
{
return
return
...
@@ -250,17 +282,17 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id)
...
@@ -250,17 +282,17 @@ void Taggroup_Remove (taggroup_t *garray[], const mtag_t tag, size_t id)
static
void
Taglist_AddToSectors
(
const
mtag_t
tag
,
const
size_t
itemid
)
static
void
Taglist_AddToSectors
(
const
mtag_t
tag
,
const
size_t
itemid
)
{
{
Taggroup_Add
(
tags_sectors
,
tag
,
itemid
);
Taggroup_Add
_Init
(
tags_sectors
,
tag
,
itemid
);
}
}
static
void
Taglist_AddToLines
(
const
mtag_t
tag
,
const
size_t
itemid
)
static
void
Taglist_AddToLines
(
const
mtag_t
tag
,
const
size_t
itemid
)
{
{
Taggroup_Add
(
tags_lines
,
tag
,
itemid
);
Taggroup_Add
_Init
(
tags_lines
,
tag
,
itemid
);
}
}
static
void
Taglist_AddToMapthings
(
const
mtag_t
tag
,
const
size_t
itemid
)
static
void
Taglist_AddToMapthings
(
const
mtag_t
tag
,
const
size_t
itemid
)
{
{
Taggroup_Add
(
tags_mapthings
,
tag
,
itemid
);
Taggroup_Add
_Init
(
tags_mapthings
,
tag
,
itemid
);
}
}
/// After all taglists have been built for each element (sectors, lines, things),
/// After all taglists have been built for each element (sectors, lines, things),
...
...
This diff is collapsed.
Click to expand it.
src/taglist.h
+
1
−
0
View file @
3248556f
...
@@ -41,6 +41,7 @@ typedef struct
...
@@ -41,6 +41,7 @@ typedef struct
{
{
size_t
*
elements
;
size_t
*
elements
;
size_t
count
;
size_t
count
;
size_t
capacity
;
}
taggroup_t
;
}
taggroup_t
;
extern
bitarray_t
tags_available
[];
extern
bitarray_t
tags_available
[];
...
...
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