diff --git a/docs/buffer-swap-rfc.md b/docs/buffer-swap-rfc.md index 52fc95f..7c3e828 100644 --- a/docs/buffer-swap-rfc.md +++ b/docs/buffer-swap-rfc.md @@ -2,11 +2,11 @@ ## Summary -`buffer.swap(b, x, y, range?)` swaps a variable `range(?=1)` of bytes stored at offsets `x` and `y` of buffer `b` +`buffer.swap(b, x, y, range?)` swaps a variable `range(?=1)` of bytes stored at offsets `x` and `y` of buffer `b`. ## Motivation -The absence of a byte-range-swap function implies that for any variable range of bytes that need to be swapped, these bytes would have to be normalized as strings (see *Design*), *then* written back into the buffer. Although the implementation works, it would make more sense to have a buffer function that interally manipulates the desired offsets/range of bytes instead of the provided method where the byte ranges are interpreted as strings to achieve the same result +The absence of a byte-range-swap function implies that for any variable range of bytes that need to be swapped, these bytes would have to be normalized as strings (see *Design*), *then* written back into the buffer. Although the implementation works, it would make more sense to have a buffer function that interally manipulates the desired offsets/range of bytes instead of the provided method where the byte ranges are interpreted as strings to achieve the same result. In short, the current swap implementation has a string "layer" (unneccessary complexity/operations/conversions? (conjecture)), whereas the proposal for `buffer.swap( ... )` internally manipulates the byte ranges without any string interpretations etc. @@ -35,10 +35,10 @@ print(buffer.readf32(b, 4)) --- 3.14... is now at 4 ## Drawbacks -Real use-cases may be sparse, where this rfc could be interpreted as having added bloat to the buffer library +Real use-cases may be sparse, where this rfc could be interpreted as having added bloat to the buffer library. ## Alternatives -`is:pr is:open buffer.swap` search query on `/luau-lang/rfcs/pulls` returns no results +`is:pr is:open buffer.swap` search query on `/luau-lang/rfcs/pulls` returns no results. -`buffer.swap[u/i/f/string/...][8/16/32/64/...](b, x, y, range?)` (a case for each buffer type) was initially considered but that would very quickly become a nightmare for managing code. The provided working implementation is shown because (despite normalizing bytes as strings) it most-closely represents the goal of this rfc +`buffer.swap[u/i/f/string/...][8/16/32/64/...](b, x, y, range?)` (a case for each buffer type) was initially considered but that would very quickly become a nightmare for managing code. The provided working implementation is shown because (despite normalizing bytes as strings) it most-closely represents the goal of this rfc.