Skip to content

Commit 2261c6c

Browse files
Update README.md
1 parent 71bbeef commit 2261c6c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,11 @@ Measured on i7-4770 with 40-character strings in each element. For associative a
214214
</details>
215215

216216
## Limitations
217-
- Unsetting elements is relatively slow because it requires processing all current indices/keys in the array as a string. To work around this, when possible, assign an empty string as a value to the element instead of unsetting the element. Alternatively, if you want to free up the memory used by the array, use the `unset_[x]_arr()` functions which work hundreds of times faster than unsetting individual elements.
218-
- By default, functions that output all indices/keys/values do not sort the output. This is different from Bash arrays behavior which sorts the output. The reason for this is that sorting is relatively slow and in most cases not required. When sorted output is required, use the functions with the `-s` option to get a sorted (by index/key) output. Once sorting occurs, the array will stay sorted until some changes have been applied to it. In some cases, the functions are able to maintain the sorted state when setting elements and in other cases not, as described in the `Sorting an array` sections above. Unsetting elements doesn't affect the sorted/unsorted state of arrays. An optimization has been implemented which buffers unsorted keys/indices, so when a sorted output is required, usually only a part of the keys/indices need to be sorted which improves the performance for such workloads.
217+
- Unsetting individual elements is relatively slow because it requires to process all current indices/keys in the array as a string. To work around this, when possible, assign an empty string as a value to the element instead of unsetting the element. Alternatively, if you want to free up the memory used by the array, use the `unset_[x]_arr()` functions which work hundreds of times faster than unsetting individual elements. Optimizations have been implemented which cover unsetting elements sequentially from the 1st one upwards or from the last one downwards (in the order in which the elements are stored), so under these conditions unsetting elements does not incur a large performance hit.
218+
- By default, functions that output all indices/keys/values do not sort the output. This is different from Bash arrays behavior which sorts the output. The reason for this is that sorting is relatively slow and in most cases not required. When sorted output is required, use the functions with the `-s` option to get a sorted (by index/key) output. Once sorting occurs, the array will stay sorted until new elements are set. In some cases, the functions are able to maintain the sorted state when setting elements and in other cases not, as described in the `Sorting an array` sections above. Unsetting elements doesn't affect the sorted/unsorted state of arrays. An optimization has been implemented which buffers unsorted keys/indices. This minimizes performance hit for workloads which require sorting.
219+
- For indexed arrays, the `get_i_arr_max_index()` and `get_i_arr_last_value()` functions require the array to be sorted and hence when called, sorting of the array will occur. Which, as mentioned above, is relatively slow.
219220
- Array names and (for associative arrays) keys are limited to English alphanumeric characters and underlines - `_`.
220-
- Functions have been tested exclusively with the `POSIX` (or `C`) locale and are likely to misbehave in some other locales. This may manifest in functions complaining about invalid array names or keys, or incorrect sorting, or even the unset functions working incorrectly. The `posix-arrays.sh` script exports the `LC_ALL` variable to avoid such issues. Note that sourcing this script will change the locale to C in the current shell the script is running in and its subshells (this won't stick when the script exits).
221+
- Functions have been tested exclusively with the `POSIX` (or `C`) locale and are likely to misbehave in some other locales. This may manifest in functions complaining about invalid array names or keys, or incorrect sorting, or even the unset functions working incorrectly. To avoid such issues, the `posix-arrays.sh` script exports the `LC_ALL` variable. Note that sourcing this script will change the locale to C in the current shell the script is running in and its subshells (this won't stick when the script exits).
221222

222223
## Some more details
223224
- The values are stored in dynamically created variables. The name of such variable is in the format `_[x]_[arr_name]_[key/index]`, where `[x]` stands for the type of the array: `a` for associative array, `i` for indexed array.

0 commit comments

Comments
 (0)