From 68111da0a258b8f0cb92fe81a94e4b167837a5b8 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 2 Apr 2024 11:50:37 +0200 Subject: [PATCH] Improved performance --- README.md | 6 +++--- Render.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c283397..5d653b8 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,9 @@ coverage: 100.0% of statements ## Benchmarks ``` -BenchmarkSmall-12 7223979 164.2 ns/op 64 B/op 2 allocs/op -BenchmarkMedium-12 832531 1310 ns/op 992 B/op 2 allocs/op -BenchmarkLarge-12 295946 3732 ns/op 3712 B/op 3 allocs/op +BenchmarkSmall-12 8899971 131.5 ns/op 32 B/op 1 allocs/op +BenchmarkMedium-12 980007 1217 ns/op 512 B/op 1 allocs/op +BenchmarkLarge-12 315229 3554 ns/op 2560 B/op 2 allocs/op ``` ## License diff --git a/Render.go b/Render.go index 024803c..862b53c 100644 --- a/Render.go +++ b/Render.go @@ -3,6 +3,7 @@ package markdown import ( "html" "strings" + "unsafe" ) var ( @@ -40,7 +41,7 @@ func Render(markdown string) string { r.WriteString("") } - return string(r.out) + return unsafe.String(unsafe.SliceData(r.out), len(r.out)) } if i != len(markdown) && markdown[i] != '\n' {