Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
Mirai
Commits
43cb22e0
Commit
43cb22e0
authored
Dec 15, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove MutableContactList
parent
c4b42a31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
25 deletions
+16
-25
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
+2
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
.../commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
+12
-20
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/action/GroupPacket.kt
...e.mirai/network/protocol/tim/packet/action/GroupPacket.kt
+2
-1
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
View file @
43cb22e0
...
...
@@ -106,11 +106,9 @@ internal class BotImpl @PublishedApi internal constructor(
// endregion
// region contacts
@UseExperimental
(
MiraiInternalAPI
::
class
)
override
val
groups
:
ContactList
<
Group
>
=
ContactList
(
MutableContactList
())
override
val
groups
:
ContactList
<
Group
>
=
ContactList
(
LockFreeLinkedList
())
@UseExperimental
(
MiraiInternalAPI
::
class
)
override
val
qqs
:
ContactList
<
QQ
>
=
ContactList
(
MutableContactList
())
override
val
qqs
:
ContactList
<
QQ
>
=
ContactList
(
LockFreeLinkedList
())
/**
* 线程安全地获取缓存的 QQ 对象. 若没有对应的缓存, 则会创建一个.
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
View file @
43cb22e0
...
...
@@ -12,7 +12,7 @@ import net.mamoe.mirai.utils.joinToString
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
@Suppress
(
"unused"
)
class
ContactList
<
C
:
Contact
>(
@PublishedApi
internal
val
delegate
:
MutableContact
List
<
C
>)
{
class
ContactList
<
C
:
Contact
>(
@PublishedApi
internal
val
delegate
:
LockFreeLinked
List
<
C
>)
{
/**
* ID 列表的字符串表示.
* 如:
...
...
@@ -35,22 +35,14 @@ class ContactList<C : Contact>(@PublishedApi internal val delegate: MutableConta
override
fun
toString
():
String
=
delegate
.
joinToString
(
separator
=
", "
,
prefix
=
"ContactList("
,
postfix
=
")"
)
}
/**
* 可修改联系人列表. 只会在内部使用.
*/
@MiraiInternalAPI
class
MutableContactList
<
C
:
Contact
>
:
LockFreeLinkedList
<
C
>()
{
override
fun
toString
():
String
=
joinToString
(
separator
=
", "
,
prefix
=
"MutableContactList("
,
postfix
=
")"
)
operator
fun
get
(
id
:
UInt
):
C
{
forEach
{
if
(
it
.
id
==
id
)
return
it
}
throw
NoSuchElementException
()
}
fun
getOrNull
(
id
:
UInt
):
C
?
{
forEach
{
if
(
it
.
id
==
id
)
return
it
}
return
null
}
fun
getOrAdd
(
id
:
UInt
,
supplier
:
()
->
C
):
C
=
super
.
filteringGetOrAdd
({
it
.
id
==
id
},
supplier
)
}
\ No newline at end of file
operator
fun
<
C
:
Contact
>
LockFreeLinkedList
<
C
>.
get
(
id
:
UInt
):
C
{
forEach
{
if
(
it
.
id
==
id
)
return
it
}
throw
NoSuchElementException
()
}
fun
<
C
:
Contact
>
LockFreeLinkedList
<
C
>.
getOrNull
(
id
:
UInt
):
C
?
{
forEach
{
if
(
it
.
id
==
id
)
return
it
}
return
null
}
fun
<
C
:
Contact
>
LockFreeLinkedList
<
C
>.
getOrAdd
(
id
:
UInt
,
supplier
:
()
->
C
):
C
=
filteringGetOrAdd
({
it
.
id
==
id
},
supplier
)
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/action/GroupPacket.kt
View file @
43cb22e0
...
...
@@ -10,6 +10,7 @@ import net.mamoe.mirai.message.internal.toPacket
import
net.mamoe.mirai.network.BotNetworkHandler
import
net.mamoe.mirai.network.protocol.tim.TIMProtocol
import
net.mamoe.mirai.network.protocol.tim.packet.*
import
net.mamoe.mirai.utils.LockFreeLinkedList
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
net.mamoe.mirai.utils.io.*
import
net.mamoe.mirai.withSession
...
...
@@ -54,7 +55,7 @@ internal data class RawGroupInfo(
@Suppress
(
"NOTHING_TO_INLINE"
)
// this function it only executed in one place.
@UseExperimental
(
MiraiInternalAPI
::
class
)
inline
fun
parseBy
(
group
:
Group
):
GroupInfo
=
group
.
bot
.
withSession
{
val
memberList
=
MutableContact
List
<
Member
>()
val
memberList
=
LockFreeLinked
List
<
Member
>()
members
.
forEach
{
entry
:
Map
.
Entry
<
UInt
,
MemberPermission
>
->
entry
.
key
.
qq
().
let
{
group
.
Member
(
it
,
entry
.
value
,
it
.
coroutineContext
)
}
}
...
...
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