Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
a4632d6e
J
jadx
项目概览
qq_39073359
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4632d6e
编写于
9月 04, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix high memory usage while process conditions
上级
2a3162f8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
87 addition
and
20 deletion
+87
-20
jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfInfo.java
...rc/main/java/jadx/core/dex/regions/conditions/IfInfo.java
+14
-9
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+3
-11
jadx-core/src/test/java/jadx/tests/internal/conditions/TestConditions15.java
...java/jadx/tests/internal/conditions/TestConditions15.java
+70
-0
未找到文件。
jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfInfo.java
浏览文件 @
a4632d6e
...
...
@@ -3,8 +3,6 @@ package jadx.core.dex.regions.conditions;
import
jadx.core.dex.nodes.BlockNode
;
import
java.util.HashSet
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
public
final
class
IfInfo
{
...
...
@@ -12,13 +10,13 @@ public final class IfInfo {
private
final
Set
<
BlockNode
>
mergedBlocks
;
private
final
BlockNode
thenBlock
;
private
final
BlockNode
elseBlock
;
private
final
Lis
t
<
BlockNode
>
skipBlocks
;
private
final
Se
t
<
BlockNode
>
skipBlocks
;
private
BlockNode
outBlock
;
@Deprecated
private
BlockNode
ifBlock
;
public
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
)
{
this
(
condition
,
thenBlock
,
elseBlock
,
new
HashSet
<
BlockNode
>(),
new
LinkedLis
t
<
BlockNode
>());
this
(
condition
,
thenBlock
,
elseBlock
,
new
HashSet
<
BlockNode
>(),
new
HashSe
t
<
BlockNode
>());
}
public
IfInfo
(
IfCondition
condition
,
IfInfo
info
)
{
...
...
@@ -30,7 +28,7 @@ public final class IfInfo {
}
private
IfInfo
(
IfCondition
condition
,
BlockNode
thenBlock
,
BlockNode
elseBlock
,
Set
<
BlockNode
>
mergedBlocks
,
Lis
t
<
BlockNode
>
skipBlocks
)
{
Set
<
BlockNode
>
mergedBlocks
,
Se
t
<
BlockNode
>
skipBlocks
)
{
this
.
condition
=
condition
;
this
.
thenBlock
=
thenBlock
;
this
.
elseBlock
=
elseBlock
;
...
...
@@ -47,6 +45,13 @@ public final class IfInfo {
return
tmpIf
;
}
public
void
merge
(
IfInfo
...
arr
)
{
for
(
IfInfo
info
:
arr
)
{
mergedBlocks
.
addAll
(
info
.
getMergedBlocks
());
skipBlocks
.
addAll
(
info
.
getSkipBlocks
());
}
}
public
IfCondition
getCondition
()
{
return
condition
;
}
...
...
@@ -55,6 +60,10 @@ public final class IfInfo {
return
mergedBlocks
;
}
public
Set
<
BlockNode
>
getSkipBlocks
()
{
return
skipBlocks
;
}
public
BlockNode
getThenBlock
()
{
return
thenBlock
;
}
...
...
@@ -71,10 +80,6 @@ public final class IfInfo {
this
.
outBlock
=
outBlock
;
}
public
List
<
BlockNode
>
getSkipBlocks
()
{
return
skipBlocks
;
}
public
BlockNode
getIfBlock
()
{
return
ifBlock
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
浏览文件 @
a4632d6e
...
...
@@ -190,12 +190,7 @@ public class IfMakerHelper {
nextThen
.
getCondition
(),
nextElse
.
getCondition
());
IfInfo
result
=
new
IfInfo
(
newCondition
,
nextThen
.
getThenBlock
(),
nextThen
.
getElseBlock
());
result
.
setIfBlock
(
currentIf
.
getIfBlock
());
result
.
getMergedBlocks
().
addAll
(
currentIf
.
getMergedBlocks
());
result
.
getMergedBlocks
().
addAll
(
nextThen
.
getMergedBlocks
());
result
.
getMergedBlocks
().
addAll
(
nextElse
.
getMergedBlocks
());
result
.
getSkipBlocks
().
addAll
(
currentIf
.
getSkipBlocks
());
result
.
getSkipBlocks
().
addAll
(
nextThen
.
getSkipBlocks
());
result
.
getSkipBlocks
().
addAll
(
nextElse
.
getSkipBlocks
());
result
.
merge
(
currentIf
,
nextThen
,
nextElse
);
confirmMerge
(
result
);
return
result
;
}
...
...
@@ -215,10 +210,7 @@ public class IfMakerHelper {
IfCondition
condition
=
IfCondition
.
merge
(
mergeOperation
,
first
.
getCondition
(),
second
.
getCondition
());
IfInfo
result
=
new
IfInfo
(
condition
,
second
);
result
.
setIfBlock
(
first
.
getIfBlock
());
result
.
getMergedBlocks
().
addAll
(
first
.
getMergedBlocks
());
result
.
getMergedBlocks
().
addAll
(
second
.
getMergedBlocks
());
result
.
getSkipBlocks
().
addAll
(
first
.
getSkipBlocks
());
result
.
getSkipBlocks
().
addAll
(
second
.
getSkipBlocks
());
result
.
merge
(
first
,
second
);
BlockNode
otherPathBlock
=
followThenBranch
?
first
.
getElseBlock
()
:
first
.
getThenBlock
();
skipSimplePath
(
otherPathBlock
,
result
.
getSkipBlocks
());
...
...
@@ -303,7 +295,7 @@ public class IfMakerHelper {
return
null
;
}
private
static
void
skipSimplePath
(
BlockNode
block
,
Lis
t
<
BlockNode
>
skipped
)
{
private
static
void
skipSimplePath
(
BlockNode
block
,
Se
t
<
BlockNode
>
skipped
)
{
while
(
block
!=
null
&&
block
.
getCleanSuccessors
().
size
()
<
2
&&
block
.
getPredecessors
().
size
()
==
1
)
{
...
...
jadx-core/src/test/java/jadx/tests/internal/conditions/TestConditions15.java
0 → 100644
浏览文件 @
a4632d6e
package
jadx.tests.internal.conditions
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestConditions15
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
static
boolean
test
(
final
String
name
)
{
if
(
isEmpty
(
name
))
{
return
false
;
}
if
(
"1"
.
equals
(
name
)
||
"2"
.
equals
(
name
)
||
"3"
.
equals
(
name
)
||
"4"
.
equals
(
name
)
||
"5"
.
equals
(
name
)
||
"6"
.
equals
(
name
)
||
"7"
.
equals
(
name
)
||
"8"
.
equals
(
name
)
||
"9"
.
equals
(
name
)
||
"10"
.
equals
(
name
)
||
"11"
.
equals
(
name
)
||
"12"
.
equals
(
name
)
||
"13"
.
equals
(
name
)
||
"14"
.
equals
(
name
)
||
"15"
.
equals
(
name
)
||
"16"
.
equals
(
name
)
||
"17"
.
equals
(
name
)
||
"18"
.
equals
(
name
)
||
"19"
.
equals
(
name
)
||
"20"
.
equals
(
name
)
||
"22"
.
equals
(
name
)
||
"22"
.
equals
(
name
)
||
"23"
.
equals
(
name
)
||
"24"
.
equals
(
name
)
||
"25"
.
equals
(
name
)
||
"26"
.
equals
(
name
)
||
"27"
.
equals
(
name
)
||
"28"
.
equals
(
name
)
||
"29"
.
equals
(
name
)
||
"30"
.
equals
(
name
))
{
return
false
;
}
else
{
return
true
;
}
}
private
static
boolean
isEmpty
(
String
name
)
{
return
name
.
isEmpty
();
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"\"1\".equals(name)"
));
assertThat
(
code
,
containsOne
(
"\"30\".equals(name)"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录