Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Julien Lopez
QueryR
Commits
814e241c
Commit
814e241c
authored
7 years ago
by
Florian Angerer
Browse files
Options
Downloads
Patches
Plain Diff
Removed unnecessary allocations in builtin 'aperm'.
parent
71ac97ad
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/APerm.java
+7
-13
7 additions, 13 deletions
...in/src/com/oracle/truffle/r/nodes/builtin/base/APerm.java
with
7 additions
and
13 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/APerm.java
+
7
−
13
View file @
814e241c
...
...
@@ -18,7 +18,6 @@ import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
builtins
.
RBehavior
.
PURE
;
import
static
com
.
oracle
.
truffle
.
r
.
runtime
.
builtins
.
RBuiltinKind
.
INTERNAL
;
import
com.oracle.truffle.api.CompilerDirectives.TruffleBoundary
;
import
com.oracle.truffle.api.dsl.Cached
;
import
com.oracle.truffle.api.dsl.Specialization
;
import
com.oracle.truffle.api.profiles.BranchProfile
;
...
...
@@ -129,7 +128,7 @@ public abstract class APerm extends RBuiltinNode.Arg3 {
for
(
int
i
=
0
;
i
<
result
.
getLength
();
i
++)
{
int
pos
=
toPos
(
applyPermute
(
posV
,
perm
,
true
),
dim
);
result
.
transferElementSameType
(
i
,
vector
,
pos
);
posV
=
incArray
(
posV
,
pDim
);
incArray
(
posV
,
pDim
);
}
RList
dimNames
=
getDimNamesNode
.
getDimNames
(
vector
);
...
...
@@ -219,7 +218,6 @@ public abstract class APerm extends RBuiltinNode.Arg3 {
/**
* Apply permute to an equal sized array.
*/
@TruffleBoundary
private
static
int
[]
applyPermute
(
int
[]
a
,
int
[]
perm
,
boolean
reverse
)
{
int
[]
newA
=
a
.
clone
();
if
(
reverse
)
{
...
...
@@ -235,25 +233,21 @@ public abstract class APerm extends RBuiltinNode.Arg3 {
}
/**
* Increment a stride array.
* Increment a stride array.
Note: First input array may be modified.
*/
@TruffleBoundary
private
static
int
[]
incArray
(
int
[]
a
,
int
[]
dim
)
{
int
[]
newA
=
a
.
clone
();
for
(
int
i
=
0
;
i
<
newA
.
length
;
i
++)
{
newA
[
i
]++;
if
(
newA
[
i
]
<
dim
[
i
])
{
private
static
void
incArray
(
int
[]
a
,
int
[]
dim
)
{
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
a
[
i
]++;
if
(
a
[
i
]
<
dim
[
i
])
{
break
;
}
newA
[
i
]
=
0
;
a
[
i
]
=
0
;
}
return
newA
;
}
/**
* Stride array to a linear position.
*/
@TruffleBoundary
private
static
int
toPos
(
int
[]
a
,
int
[]
dim
)
{
int
pos
=
a
[
0
];
for
(
int
i
=
1
;
i
<
a
.
length
;
i
++)
{
...
...
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