Merge pull request #2146 from 821938089/little-fix

优化
This commit is contained in:
kunfei
2022-08-10 19:21:41 +08:00
committed by GitHub
2 changed files with 4 additions and 6 deletions

View File

@@ -98,17 +98,15 @@ object BookHelp {
book: Book,
bookChapter: BookChapter,
content: String
) {
) = coroutineScope {
val awaitList = arrayListOf<Deferred<Unit>>()
content.split("\n").forEach {
val matcher = AppPattern.imgPattern.matcher(it)
if (matcher.find()) {
matcher.group(1)?.let { src ->
val mSrc = NetworkUtils.getAbsoluteURL(bookChapter.url, src)
awaitList.add(coroutineScope {
async {
saveImage(bookSource, book, mSrc)
}
awaitList.add(async {
saveImage(bookSource, book, mSrc)
})
}
}

View File

@@ -149,7 +149,7 @@ class Coroutine<T>(
try {
start?.let { dispatchVoidCallback(this, it) }
ensureActive()
val value = executeBlock(scope, context, timeMillis ?: 0L, block)
val value = executeBlock(this, context, timeMillis ?: 0L, block)
ensureActive()
success?.let { dispatchCallback(this, value, it) }
} catch (e: Throwable) {