Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
71e04d62
Commit
71e04d62
authored
Dec 06, 2015
by
John Kessenich
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #100 from mawww/scanner-optim
Scanner optimisations
parents
27657498
6998987e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
Scan.cpp
glslang/MachineIndependent/Scan.cpp
+27
-4
PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
+0
-0
No files found.
glslang/MachineIndependent/Scan.cpp
View file @
71e04d62
...
...
@@ -293,10 +293,33 @@ int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext)
namespace
{
struct
str_eq
{
bool
operator
()(
const
char
*
lhs
,
const
char
*
rhs
)
const
{
return
strcmp
(
lhs
,
rhs
)
==
0
;
}
};
struct
str_hash
{
size_t
operator
()(
const
char
*
str
)
const
{
// djb2
unsigned
long
hash
=
5381
;
int
c
;
while
(
c
=
*
str
++
)
hash
=
((
hash
<<
5
)
+
hash
)
+
c
;
return
hash
;
}
};
// A single global usable by all threads, by all versions, by all languages.
// After a single process-level initialization, this is read only and thread safe
std
::
unordered_map
<
std
::
string
,
int
>*
KeywordMap
=
nullptr
;
std
::
unordered_set
<
std
::
string
>*
ReservedSet
=
nullptr
;
std
::
unordered_map
<
const
char
*
,
int
,
str_hash
,
str_eq
>*
KeywordMap
=
nullptr
;
std
::
unordered_set
<
const
char
*
,
str_hash
,
str_eq
>*
ReservedSet
=
nullptr
;
};
...
...
@@ -309,7 +332,7 @@ void TScanContext::fillInKeywordMap()
// but, the only risk is if two threads called simultaneously
return
;
}
KeywordMap
=
new
std
::
unordered_map
<
std
::
string
,
int
>
;
KeywordMap
=
new
std
::
unordered_map
<
const
char
*
,
int
,
str_hash
,
str_eq
>
;
(
*
KeywordMap
)[
"const"
]
=
CONST
;
(
*
KeywordMap
)[
"uniform"
]
=
UNIFORM
;
...
...
@@ -481,7 +504,7 @@ void TScanContext::fillInKeywordMap()
(
*
KeywordMap
)[
"resource"
]
=
RESOURCE
;
(
*
KeywordMap
)[
"superp"
]
=
SUPERP
;
ReservedSet
=
new
std
::
unordered_set
<
std
::
string
>
;
ReservedSet
=
new
std
::
unordered_set
<
const
char
*
,
str_hash
,
str_eq
>
;
ReservedSet
->
insert
(
"common"
);
ReservedSet
->
insert
(
"partition"
);
...
...
glslang/MachineIndependent/preprocessor/PpScanner.cpp
View file @
71e04d62
This diff is collapsed.
Click to expand it.
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