Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
QuasselDroid-ng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
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
Janne Mareike Koschinski
QuasselDroid-ng
Commits
0c3ae0f8
Commit
0c3ae0f8
authored
6 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Preformance improvements
parent
c7d3208a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/de/kuschku/quasseldroid/util/irc/format/IrcFormatDeserializer.kt
+15
-16
15 additions, 16 deletions
...hku/quasseldroid/util/irc/format/IrcFormatDeserializer.kt
with
15 additions
and
16 deletions
app/src/main/java/de/kuschku/quasseldroid/util/irc/format/IrcFormatDeserializer.kt
+
15
−
16
View file @
0c3ae0f8
...
@@ -22,7 +22,6 @@ package de.kuschku.quasseldroid.util.irc.format
...
@@ -22,7 +22,6 @@ package de.kuschku.quasseldroid.util.irc.format
import
android.content.Context
import
android.content.Context
import
android.text.SpannableStringBuilder
import
android.text.SpannableStringBuilder
import
de.kuschku.quasseldroid.R
import
de.kuschku.quasseldroid.R
import
de.kuschku.quasseldroid.util.compatibility.AndroidCrashFixer
import
de.kuschku.quasseldroid.util.helper.getColorCompat
import
de.kuschku.quasseldroid.util.helper.getColorCompat
import
de.kuschku.quasseldroid.util.irc.format.model.FormatDescription
import
de.kuschku.quasseldroid.util.irc.format.model.FormatDescription
import
de.kuschku.quasseldroid.util.irc.format.model.FormatInfo
import
de.kuschku.quasseldroid.util.irc.format.model.FormatInfo
...
@@ -71,11 +70,9 @@ class IrcFormatDeserializer(private val mircColors: IntArray) {
...
@@ -71,11 +70,9 @@ class IrcFormatDeserializer(private val mircColors: IntArray) {
* @param content mIRC formatted String
* @param content mIRC formatted String
* @return a CharSequence with Android’s span format representing the input string
* @return a CharSequence with Android’s span format representing the input string
*/
*/
fun
formatString
(
content
:
String
?,
colorize
:
Boolean
,
fun
formatString
(
str
:
String
?,
colorize
:
Boolean
,
output
:
MutableList
<
FormatInfo
>?
=
null
):
CharSequence
{
output
:
MutableList
<
FormatInfo
>?
=
null
):
CharSequence
{
if
(
content
==
null
)
return
""
if
(
str
==
null
)
return
""
val
str
=
AndroidCrashFixer
.
removeCrashableCharacters
(
content
)
val
plainText
=
SpannableStringBuilder
()
val
plainText
=
SpannableStringBuilder
()
var
bold
:
FormatDescription
<
IrcFormat
.
Bold
>?
=
null
var
bold
:
FormatDescription
<
IrcFormat
.
Bold
>?
=
null
...
@@ -371,12 +368,14 @@ class IrcFormatDeserializer(private val mircColors: IntArray) {
...
@@ -371,12 +368,14 @@ class IrcFormatDeserializer(private val mircColors: IntArray) {
* @return Index of first character that is not a digit
* @return Index of first character that is not a digit
*/
*/
private
fun
findEndOfNumber
(
str
:
String
,
start
:
Int
):
Int
{
private
fun
findEndOfNumber
(
str
:
String
,
start
:
Int
):
Int
{
val
validCharCodes
=
setOf
(
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
)
val
searchFrame
=
str
.
substring
(
start
)
val
searchFrame
=
str
.
substring
(
start
)
var
i
=
0
var
i
=
0
while
(
i
<
2
&&
i
<
searchFrame
.
length
)
{
loop@
while
(
i
<
2
&&
i
<
searchFrame
.
length
)
{
if
(!
validCharCodes
.
contains
(
searchFrame
[
i
]))
{
when
(
searchFrame
[
i
])
{
break
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
->
{
// Do nothing
}
else
->
break
@loop
}
}
i
++
i
++
}
}
...
@@ -389,15 +388,15 @@ class IrcFormatDeserializer(private val mircColors: IntArray) {
...
@@ -389,15 +388,15 @@ class IrcFormatDeserializer(private val mircColors: IntArray) {
* @return Index of first character that is not a digit
* @return Index of first character that is not a digit
*/
*/
private
fun
findEndOfHexNumber
(
str
:
String
,
start
:
Int
):
Int
{
private
fun
findEndOfHexNumber
(
str
:
String
,
start
:
Int
):
Int
{
val
validCharCodes
=
setOf
(
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
)
val
searchFrame
=
str
.
substring
(
start
)
val
searchFrame
=
str
.
substring
(
start
)
var
i
=
0
var
i
=
0
while
(
i
<
6
&&
i
<
searchFrame
.
length
)
{
loop@
while
(
i
<
6
&&
i
<
searchFrame
.
length
)
{
if
(!
validCharCodes
.
contains
(
searchFrame
[
i
]))
{
when
(
searchFrame
[
i
])
{
break
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
->
{
// Do nothing
}
else
->
break
@loop
}
}
i
++
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