Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
dd502147
Commit
dd502147
authored
Aug 12, 2009
by
Mark Olesen
Browse files
ISstream micro-optimizations
parent
920fa49e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C
View file @
dd502147
...
...
@@ -45,38 +45,44 @@ char Foam::ISstream::nextValid()
// Return if stream is bad - ie, previous get() failed
if
(
bad
()
||
isspace
(
c
))
{
re
turn
0
;
b
re
ak
;
}
// Is this the start of a C/C++ comment?
if
(
c
==
'/'
)
{
// If cannot get another character, return this one
if
(
!
get
(
c
))
{
// cannot get another character - return this one
return
'/'
;
}
if
(
c
==
'/'
)
{
//
This is the start of a
C++ style
on
e-line comment
// C++ style
singl
e-line comment
- skip through past end-of-line
while
(
get
(
c
)
&&
c
!=
'\n'
)
{}
}
else
if
(
c
==
'*'
)
{
//
This is the start of
a C
style comment
//
within
a C
-
style comment
while
(
true
)
{
// search for end of C-style comment - '*/'
if
(
get
(
c
)
&&
c
==
'*'
)
{
if
(
get
(
c
)
&&
c
==
'/'
)
if
(
get
(
c
))
{
break
;
}
else
{
putback
(
c
);
if
(
c
==
'/'
)
{
// matched '*/'
break
;
}
else
if
(
c
==
'*'
)
{
// check again
putback
(
c
);
}
}
}
...
...
@@ -86,17 +92,21 @@ char Foam::ISstream::nextValid()
}
}
}
else
// A lone '/' so return it.
else
{
// The '/' did not start a C/C++ comment - return it
putback
(
c
);
return
'/'
;
}
}
else
// c is a valid character so return it
else
{
// a valid character - return it
return
c
;
}
}
return
0
;
}
...
...
@@ -277,8 +287,8 @@ Foam::Istream& Foam::ISstream::read(token& t)
// }
}
// nothing converted
(
bad format
),
or trailing junk
if
(
endptr
==
buf
||
*
endptr
!=
'\0'
)
// not
everyt
hing converted
:
bad format or trailing junk
if
(
*
endptr
)
{
t
.
setBad
();
}
...
...
@@ -289,7 +299,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
}
// Should be a word (which can be a single character)
// Should be a word (which can
also
be a single character)
default:
{
putback
(
c
);
...
...
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