diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..8351ce3 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +## Translation of `highlighter.c` into Go + +This repo contains `highlighter.c` and `highlighter.go`. The latter is a translation of the former. As a result of being translated from C, it contains two functions -- `append` and `at` -- that make use of unsafe operations. Additionally, the entry function appends a NULL byte, which results in an unfortunate allocation. It does work, however, and is decently fast. + +In order to test equivalence, there's a simple fuzz test, runnable with `go test -v -fuzz FuzzComparison` using Go ≥1.18. + +The goal here is to get rid of the unsafe operations in `highlighter.go` and to get rid of the NULL byte addition. + +It would be nice to do this with as few changes as possible. For example, functions like `isCaselessSame` or `isValidIPv6` may have similar functions in the standard library, but those might possibly behave differently in subtle ways. Rather than trying to rewrite _everything_, it is preferable to simply work on replacing the bespoke representation of strings and string slices, in order to remove the unsafe operations and get rid of the NULL byte addition. Additionally, keeping the structure close to the original C implementation makes it easier to maintain moving forward. |
