Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
8ce99d43
Commit
8ce99d43
authored
Jul 13, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine json parsing
parent
43f5738c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
...in/java/com/github/shadowsocks/database/ProfileManager.kt
+2
-6
No files found.
core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
View file @
8ce99d43
...
...
@@ -27,8 +27,7 @@ import com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.forEachTry
import
com.github.shadowsocks.utils.printLog
import
com.google.gson.JsonParser
import
com.google.gson.stream.JsonReader
import
com.google.gson.JsonStreamParser
import
org.json.JSONArray
import
java.io.IOException
import
java.io.InputStream
...
...
@@ -55,7 +54,6 @@ object ProfileManager {
return
profile
}
private
val
jsonParser
=
JsonParser
()
fun
createProfilesFromJson
(
jsons
:
Sequence
<
InputStream
>,
replace
:
Boolean
=
false
)
{
val
profiles
=
if
(
replace
)
getAllProfiles
()
?.
associateBy
{
it
.
formattedAddress
}
else
null
val
feature
=
if
(
replace
)
{
...
...
@@ -63,9 +61,7 @@ object ProfileManager {
}
else
Core
.
currentProfile
?.
first
val
lazyClear
=
lazy
{
clear
()
}
jsons
.
asIterable
().
forEachTry
{
json
->
Profile
.
parseJson
(
jsonParser
.
parse
(
JsonReader
(
json
.
bufferedReader
()).
apply
{
isLenient
=
true
}),
feature
)
{
Profile
.
parseJson
(
JsonStreamParser
(
json
.
bufferedReader
()).
asSequence
().
single
(),
feature
)
{
if
(
replace
)
{
lazyClear
.
value
// if two profiles has the same address, treat them as the same profile and copy stats over
...
...
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