Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kengao2018
fastjson
提交
bf9a900b
fastjson
项目概览
kengao2018
/
fastjson
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
fastjson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bf9a900b
编写于
8月 20, 2018
作者:
W
wenshao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improved performance.
上级
ee614b6e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
26 deletion
+50
-26
src/main/java/com/alibaba/fastjson/JSONArray.java
src/main/java/com/alibaba/fastjson/JSONArray.java
+18
-12
src/main/java/com/alibaba/fastjson/JSONPath.java
src/main/java/com/alibaba/fastjson/JSONPath.java
+13
-11
src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
...n/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
+1
-1
src/main/java/com/alibaba/fastjson/parser/deserializer/TimeDeserializer.java
...libaba/fastjson/parser/deserializer/TimeDeserializer.java
+3
-0
src/main/java/com/alibaba/fastjson/util/IOUtils.java
src/main/java/com/alibaba/fastjson/util/IOUtils.java
+2
-1
src/main/java/com/alibaba/fastjson/util/TypeUtils.java
src/main/java/com/alibaba/fastjson/util/TypeUtils.java
+13
-1
未找到文件。
src/main/java/com/alibaba/fastjson/JSONArray.java
浏览文件 @
bf9a900b
...
...
@@ -302,11 +302,12 @@ public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAc
public
byte
getByteValue
(
int
index
)
{
Object
value
=
get
(
index
);
if
(
value
==
null
)
{
Byte
byteVal
=
castToByte
(
value
);
if
(
byteVal
==
null
)
{
return
0
;
}
return
castToByte
(
value
)
.
byteValue
();
return
byteVal
.
byteValue
();
}
public
Short
getShort
(
int
index
)
{
...
...
@@ -318,11 +319,12 @@ public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAc
public
short
getShortValue
(
int
index
)
{
Object
value
=
get
(
index
);
if
(
value
==
null
)
{
Short
shortVal
=
castToShort
(
value
);
if
(
shortVal
==
null
)
{
return
0
;
}
return
castToShort
(
value
)
.
shortValue
();
return
shortVal
.
shortValue
();
}
public
Integer
getInteger
(
int
index
)
{
...
...
@@ -334,11 +336,12 @@ public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAc
public
int
getIntValue
(
int
index
)
{
Object
value
=
get
(
index
);
if
(
value
==
null
)
{
Integer
intVal
=
castToInt
(
value
);
if
(
intVal
==
null
)
{
return
0
;
}
return
castToInt
(
value
)
.
intValue
();
return
intVal
.
intValue
();
}
public
Long
getLong
(
int
index
)
{
...
...
@@ -350,11 +353,12 @@ public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAc
public
long
getLongValue
(
int
index
)
{
Object
value
=
get
(
index
);
if
(
value
==
null
)
{
Long
longVal
=
castToLong
(
value
);
if
(
longVal
==
null
)
{
return
0L
;
}
return
castToLong
(
value
)
.
longValue
();
return
longVal
.
longValue
();
}
public
Float
getFloat
(
int
index
)
{
...
...
@@ -366,11 +370,12 @@ public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAc
public
float
getFloatValue
(
int
index
)
{
Object
value
=
get
(
index
);
if
(
value
==
null
)
{
Float
floatValue
=
castToFloat
(
value
);
if
(
floatValue
==
null
)
{
return
0
F
;
}
return
castToFloat
(
value
)
.
floatValue
();
return
floatValue
.
floatValue
();
}
public
Double
getDouble
(
int
index
)
{
...
...
@@ -382,11 +387,12 @@ public class JSONArray extends JSON implements List<Object>, Cloneable, RandomAc
public
double
getDoubleValue
(
int
index
)
{
Object
value
=
get
(
index
);
if
(
value
==
null
)
{
Double
doubleValue
=
castToDouble
(
value
);
if
(
doubleValue
==
null
)
{
return
0
D
;
}
return
castToDouble
(
value
);
return
doubleValue
.
doubleValue
(
);
}
public
BigDecimal
getBigDecimal
(
int
index
)
{
...
...
src/main/java/com/alibaba/fastjson/JSONPath.java
浏览文件 @
bf9a900b
...
...
@@ -782,8 +782,10 @@ public class JSONPath implements JSONAware {
}
if
(
isInt
(
startValue
.
getClass
())
&&
isInt
(
endValue
.
getClass
()))
{
Filter
filter
=
new
IntBetweenSegement
(
propertyName
,
((
Number
)
startValue
).
longValue
(),
((
Number
)
endValue
).
longValue
(),
not
);
Filter
filter
=
new
IntBetweenSegement
(
propertyName
,
TypeUtils
.
longExtractValue
((
Number
)
startValue
)
,
TypeUtils
.
longExtractValue
((
Number
)
endValue
)
,
not
);
return
filter
;
}
...
...
@@ -864,7 +866,7 @@ public class JSONPath implements JSONAware {
if
(
isInt
)
{
if
(
valueList
.
size
()
==
1
)
{
long
value
=
((
Number
)
valueList
.
get
(
0
)).
longValue
(
);
long
value
=
TypeUtils
.
longExtractValue
((
Number
)
valueList
.
get
(
0
)
);
Operator
intOp
=
not
?
Operator
.
NE
:
Operator
.
EQ
;
Filter
filter
=
new
IntOpSegement
(
propertyName
,
value
,
intOp
);
while
(
ch
==
' '
)
{
...
...
@@ -889,7 +891,7 @@ public class JSONPath implements JSONAware {
long
[]
values
=
new
long
[
valueList
.
size
()];
for
(
int
i
=
0
;
i
<
values
.
length
;
++
i
)
{
values
[
i
]
=
((
Number
)
valueList
.
get
(
i
)).
longValue
(
);
values
[
i
]
=
TypeUtils
.
longExtractValue
((
Number
)
valueList
.
get
(
i
)
);
}
Filter
filter
=
new
IntInSegement
(
propertyName
,
values
,
not
);
...
...
@@ -971,7 +973,7 @@ public class JSONPath implements JSONAware {
for
(
int
i
=
0
;
i
<
values
.
length
;
++
i
)
{
Number
item
=
(
Number
)
valueList
.
get
(
i
);
if
(
item
!=
null
)
{
values
[
i
]
=
item
.
longValue
(
);
values
[
i
]
=
TypeUtils
.
longExtractValue
(
item
);
}
}
...
...
@@ -1847,7 +1849,7 @@ public class JSONPath implements JSONAware {
}
if
(
propertyValue
instanceof
Number
)
{
long
longPropertyValue
=
((
Number
)
propertyValue
).
longValue
(
);
long
longPropertyValue
=
TypeUtils
.
longExtractValue
((
Number
)
propertyValue
);
for
(
long
value
:
values
)
{
if
(
value
==
longPropertyValue
)
{
return
!
not
;
...
...
@@ -1883,7 +1885,7 @@ public class JSONPath implements JSONAware {
}
if
(
propertyValue
instanceof
Number
)
{
long
longPropertyValue
=
((
Number
)
propertyValue
).
longValue
(
);
long
longPropertyValue
=
TypeUtils
.
longExtractValue
((
Number
)
propertyValue
);
if
(
longPropertyValue
>=
startValue
&&
longPropertyValue
<=
endValue
)
{
return
!
not
;
}
...
...
@@ -1921,7 +1923,7 @@ public class JSONPath implements JSONAware {
}
if
(
propertyValue
instanceof
Number
)
{
long
longPropertyValue
=
((
Number
)
propertyValue
).
longValue
(
);
long
longPropertyValue
=
TypeUtils
.
longExtractValue
((
Number
)
propertyValue
);
for
(
Long
value
:
values
)
{
if
(
value
==
null
)
{
continue
;
...
...
@@ -2067,7 +2069,7 @@ public class JSONPath implements JSONAware {
return
false
;
}
long
longValue
=
((
Number
)
propertyValue
).
longValue
(
);
long
longValue
=
TypeUtils
.
longExtractValue
((
Number
)
propertyValue
);
switch
(
op
)
{
case
EQ:
...
...
@@ -2547,7 +2549,7 @@ public class JSONPath implements JSONAware {
BigDecimal
decimalA
=
(
BigDecimal
)
a
;
if
(
isIntB
)
{
return
decimalA
.
equals
(
BigDecimal
.
valueOf
(
b
.
longValue
(
)));
return
decimalA
.
equals
(
BigDecimal
.
valueOf
(
TypeUtils
.
longExtractValue
(
b
)));
}
}
...
...
@@ -2567,7 +2569,7 @@ public class JSONPath implements JSONAware {
if
(
isIntB
)
{
if
(
a
instanceof
BigInteger
)
{
BigInteger
bigIntA
=
(
BigInteger
)
a
;
BigInteger
bigIntB
=
BigInteger
.
valueOf
(
b
.
longValue
(
));
BigInteger
bigIntB
=
BigInteger
.
valueOf
(
TypeUtils
.
longExtractValue
(
b
));
return
bigIntA
.
equals
(
bigIntB
);
}
...
...
src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
浏览文件 @
bf9a900b
...
...
@@ -1420,7 +1420,7 @@ public class DefaultJSONParser implements Closeable {
lexer
.
nextToken
(
JSONToken
.
LPAREN
);
accept
(
JSONToken
.
LPAREN
);
long
time
=
((
Number
)
lexer
.
integerValue
()
).
longValue
();
long
time
=
lexer
.
integerValue
(
).
longValue
();
accept
(
JSONToken
.
LITERAL_INT
);
accept
(
JSONToken
.
RPAREN
);
...
...
src/main/java/com/alibaba/fastjson/parser/deserializer/TimeDeserializer.java
浏览文件 @
bf9a900b
package
com.alibaba.fastjson.parser.deserializer
;
import
java.lang.reflect.Type
;
import
java.math.BigDecimal
;
import
com.alibaba.fastjson.JSONException
;
import
com.alibaba.fastjson.parser.DefaultJSONParser
;
...
...
@@ -47,6 +48,8 @@ public class TimeDeserializer implements ObjectDeserializer {
if
(
val
instanceof
java
.
sql
.
Time
)
{
return
(
T
)
val
;
}
else
if
(
val
instanceof
BigDecimal
)
{
return
(
T
)
new
java
.
sql
.
Time
(((
BigDecimal
)
val
).
longValueExact
());
}
else
if
(
val
instanceof
Number
)
{
return
(
T
)
new
java
.
sql
.
Time
(((
Number
)
val
).
longValue
());
}
else
if
(
val
instanceof
String
)
{
...
...
src/main/java/com/alibaba/fastjson/util/IOUtils.java
浏览文件 @
bf9a900b
...
...
@@ -727,7 +727,8 @@ public class IOUtils {
if
(((
b2
&
0xc0
)
!=
0x80
||
(
b3
&
0xc0
)
!=
0x80
||
(
b4
&
0xc0
)
!=
0x80
)
// isMalformed4
||
// shortest form check
!
Character
.
isSupplementaryCodePoint
(
uc
))
{
!(
uc
>=
0x010000
&&
uc
<
0X10FFFF
+
1
)
// !Character.isSupplementaryCodePoint(uc)
)
{
return
-
1
;
}
else
{
da
[
dp
++]
=
(
char
)
((
uc
>>>
10
)
+
(
'\
uD800
'
-
(
0x010000
>>>
10
)));
// Character.highSurrogate(uc);
...
...
src/main/java/com/alibaba/fastjson/util/TypeUtils.java
浏览文件 @
bf9a900b
...
...
@@ -458,6 +458,14 @@ public class TypeUtils{
return
new
java
.
sql
.
Date
(
longValue
);
}
public
static
long
longExtractValue
(
Number
number
)
{
if
(
number
instanceof
BigDecimal
)
{
return
((
BigDecimal
)
number
).
longValueExact
();
}
return
number
.
longValue
();
}
public
static
java
.
sql
.
Time
castToSqlTime
(
Object
value
){
if
(
value
==
null
){
return
null
;
...
...
@@ -471,10 +479,14 @@ public class TypeUtils{
if
(
value
instanceof
Calendar
){
return
new
java
.
sql
.
Time
(((
Calendar
)
value
).
getTimeInMillis
());
}
long
longValue
=
0
;
if
(
value
instanceof
Number
){
if
(
value
instanceof
BigDecimal
){
longValue
=
((
BigDecimal
)
value
).
longValueExact
();
}
else
if
(
value
instanceof
Number
){
longValue
=
((
Number
)
value
).
longValue
();
}
if
(
value
instanceof
String
){
String
strVal
=
(
String
)
value
;
if
(
strVal
.
length
()
==
0
//
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录