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
b162459e
Commit
b162459e
authored
Feb 28, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove delegation property, use object directly;
Expose `BUFFER_SIZE`.
parent
150c85c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayPool.kt
...mmonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayPool.kt
+15
-6
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/ByteArrayPool.kt
View file @
b162459e
...
...
@@ -7,18 +7,27 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@
file
:
Suppress
(
"MemberVisibilityCanBePrivate"
)
package
net.mamoe.mirai.utils.io
import
kotlinx.io.pool.DefaultPool
import
kotlinx.io.pool.ObjectPool
import
net.mamoe.mirai.utils.MiraiInternalAPI
internal
const
val
DEFAULT_BYTE_ARRAY_POOL_SIZE
=
256
internal
const
val
DEFAULT_BYTE_ARRAY_SIZE
=
81920
/
2
val
ByteArrayPool
:
ObjectPool
<
ByteArray
>
=
ByteArrayPoolImpl
/**
* 缓存 [ByteArray] 实例的 [ObjectPool]
*
* **注意**: 这是 Mirai 内部 API. 它可能在任何时刻被改动. 不要将它用于生产环境
*/
@MiraiInternalAPI
object
ByteArrayPool
:
DefaultPool
<
ByteArray
>(
256
)
{
/**
* 每一个 [ByteArray] 的大小
*/
const
val
BUFFER_SIZE
:
Int
=
81920
/
2
private
object
ByteArrayPoolImpl
:
DefaultPool
<
ByteArray
>(
DEFAULT_BYTE_ARRAY_POOL_SIZE
)
{
override
fun
produceInstance
():
ByteArray
=
ByteArray
(
DEFAULT_BYTE_ARRAY_SIZE
)
override
fun
produceInstance
():
ByteArray
=
ByteArray
(
BUFFER_SIZE
)
override
fun
clearInstance
(
instance
:
ByteArray
):
ByteArray
=
instance
}
...
...
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