Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
@kg's optimization idea.
  • Loading branch information
ilonatommy committed May 3, 2023
commit 6bee26004219a9438c4e94aa51be8b58208a3317
10 changes: 5 additions & 5 deletions src/mono/wasm/runtime/hybrid-globalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mono_wasm_new_external_root } from "./roots";
import { MonoString, MonoStringRef } from "./types";
import { Int32Ptr } from "./types/emscripten";
import { conv_string_root, js_string_to_mono_string_root, string_decoder } from "./strings";
import { setU16 } from "./memory";
import { setU16_unchecked } from "./memory";

export function mono_wasm_change_case_invariant(exceptionMessage: Int32Ptr, src: number, srcLength: number, dst: number, dstLength: number, toUpper: number) : void{
try{
Expand All @@ -16,8 +16,8 @@ export function mono_wasm_change_case_invariant(exceptionMessage: Int32Ptr, src:
if (result.length > dstLength)
result = input;

for (let i = 0; i < result.length; i++)
setU16(dst + i * 2, result.charCodeAt(i));
for (let i = 0, j = dst; i < result.length; i++, j += 2)
setU16_unchecked(j, result.charCodeAt(i));
}
catch (ex: any) {
pass_exception_details(ex, exceptionMessage);
Expand All @@ -35,8 +35,8 @@ export function mono_wasm_change_case(exceptionMessage: Int32Ptr, culture: MonoS
if (result.length > destLength)
result = input;

for (let i = 0; i < destLength; i++)
setU16(dst + i * 2, result.charCodeAt(i));
for (let i = 0, j = dst; i < result.length; i++, j += 2)
setU16_unchecked(j, result.charCodeAt(i));
}
catch (ex: any) {
pass_exception_details(ex, exceptionMessage);
Expand Down
6 changes: 5 additions & 1 deletion src/mono/wasm/runtime/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.

import monoWasmThreads from "consts:monoWasmThreads";
import { Module, runtimeHelpers } from "./globals";
import { mono_assert, MemOffset, NumberOrPointer } from "./types";
import { VoidPtr, CharPtr } from "./types/emscripten";
import cwraps, { I52Error } from "./cwraps";
import { Module, runtimeHelpers } from "./globals";

const alloca_stack: Array<VoidPtr> = [];
const alloca_buffer_size = 32 * 1024;
Expand Down Expand Up @@ -73,6 +73,10 @@ export function setU16(offset: MemOffset, value: number): void {
Module.HEAPU16[<any>offset >>> 1] = value;
}

export function setU16_unchecked(offset: MemOffset, value: number): void {
Module.HEAPU16[<any>offset >>> 1] = value;
}

export function setU32_unchecked(offset: MemOffset, value: NumberOrPointer): void {
Module.HEAPU32[<any>offset >>> 2] = <number><any>value;
}
Expand Down