Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
e3-require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Lindh Olsson
e3-require
Commits
cc598bb6
Commit
cc598bb6
authored
6 years ago
by
Dirk Zimoch
Browse files
Options
Downloads
Patches
Plain Diff
optimize ** (power) operator
parent
6d7b883b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
expr.c
+9
-5
9 additions, 5 deletions
expr.c
with
9 additions
and
5 deletions
expr.c
+
9
−
5
View file @
cc598bb6
...
@@ -66,12 +66,16 @@ static int parseValue(const char **pp, long *v)
...
@@ -66,12 +66,16 @@ static int parseValue(const char **pp, long *v)
static
long
ipow
(
long
base
,
long
exp
)
static
long
ipow
(
long
base
,
long
exp
)
{
{
long
v
;
long
val
;
if
(
exp
<
0
)
return
0
;
if
(
exp
==
2
)
return
base
*
base
;
if
(
exp
==
3
)
return
base
*
base
*
base
;
if
(
exp
==
1
)
return
base
;
if
(
exp
==
0
)
return
1
;
if
(
exp
==
0
)
return
1
;
v
=
base
;
if
(
exp
<
0
)
return
0
;
while
(
--
exp
)
v
*=
base
;
/* optimize this! */
val
=
ipow
(
base
,
exp
>>
1
);
return
v
;
val
*=
val
;
if
(
exp
&
1
)
val
*=
base
;
return
val
;
}
}
static
char
parseSep
(
const
char
**
pp
,
const
char
*
seps
)
static
char
parseSep
(
const
char
**
pp
,
const
char
*
seps
)
...
...
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