Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the bug is in Tinygo #38

Closed
radkomih opened this issue Dec 8, 2022 · 2 comments
Closed

Check if the bug is in Tinygo #38

radkomih opened this issue Dec 8, 2022 · 2 comments

Comments

@radkomih
Copy link
Collaborator

radkomih commented Dec 8, 2022

func StringToSliceU8(s string) []U8 {
	result := make([]U8, len(s))
	for _, v := range []byte(s) {
		result = append(result, U8(v)) // panic: cannot convert pointer to integer -> /tinygo/interp/memory.go:541
	}
	return result
}
@radkomih
Copy link
Collaborator Author

radkomih commented Jul 4, 2023

this way the result ends up twice the size of the input string

result := make([]U8, len(s))

should be

result := make([]U8, 0, len(s))

but it is slightly more efficient if we use

func StringToSliceU8(s string) []U8 {
	result := make([]U8, len(s))
	for i, v := range []byte(s) {
		result[i] = U8(v)
	}
	return result
}

@radkomih
Copy link
Collaborator Author

radkomih commented Jul 4, 2023

I'm closing this as I can no longer reproduce it

@radkomih radkomih closed this as completed Jul 4, 2023
failfmi pushed a commit that referenced this issue Jul 10, 2023
* update Go version to 1.20. use testify/assert instead of test_helpers impl

* remove comments related to github.com//issues/38

* pre-allocate byte slices to improve performance

* improve the test coverage

* revert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant