aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2024-12-17 15:16:17 +0000
committerLouis Pilfold <louis@lpil.uk>2024-12-17 15:16:57 +0000
commit8dc4112e8ee95d9e07f651e7b85c8d7f76a9dba0 (patch)
tree2d65c2dda0c0bba8921625b18e8f2649437675ec /src
parentf13c14377b746f082d6f704a13fe877a363e6884 (diff)
downloadgleam_stdlib-8dc4112e8ee95d9e07f651e7b85c8d7f76a9dba0.tar.gz
gleam_stdlib-8dc4112e8ee95d9e07f651e7b85c8d7f76a9dba0.zip
Remove deprecated builders
Diffstat (limited to 'src')
-rw-r--r--src/gleam/bytes_builder.gleam174
-rw-r--r--src/gleam/string_builder.gleam212
2 files changed, 0 insertions, 386 deletions
diff --git a/src/gleam/bytes_builder.gleam b/src/gleam/bytes_builder.gleam
deleted file mode 100644
index 330865f..0000000
--- a/src/gleam/bytes_builder.gleam
+++ /dev/null
@@ -1,174 +0,0 @@
-//// `BytesBuilder` is a type used for efficiently building binary content to be
-//// written to a file or a socket. Internally it is represented as tree so to
-//// append or prepend to a bytes builder is a constant time operation that
-//// allocates a new node in the tree without copying any of the content. When
-//// writing to an output stream the tree is traversed and the content is sent
-//// directly rather than copying it into a single buffer beforehand.
-////
-//// If we append one bit array to another the bit arrays must be copied to a
-//// new location in memory so that they can sit together. This behaviour
-//// enables efficient reading of the data but copying can be expensive,
-//// especially if we want to join many bit arrays together.
-////
-//// BytesBuilder is different in that it can be joined together in constant
-//// time using minimal memory, and then can be efficiently converted to a
-//// bit array using the `to_bit_array` function.
-////
-//// Byte builders are always byte aligned, so that a number of bits that is not
-//// divisible by 8 will be padded with 0s.
-////
-//// On Erlang this type is compatible with Erlang's iolists.
-
-// TODO: pad bit arrays to byte boundaries when adding to a builder.
-import gleam/bytes_tree.{type BytesTree}
-import gleam/string_tree.{type StringTree}
-
-@deprecated("The `bytes_builder` module has been deprecated, use the `bytes_tree.BytesTree` type instead.")
-pub type BytesBuilder =
- BytesTree
-
-/// Create an empty `BytesBuilder`. Useful as the start of a pipe chaining many
-/// builders together.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.new` instead.")
-pub fn new() -> BytesTree {
- bytes_tree.concat([])
-}
-
-/// Prepends a bit array to the start of a builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.prepend` instead.")
-pub fn prepend(to second: BytesTree, prefix first: BitArray) -> BytesTree {
- bytes_tree.append_tree(bytes_tree.from_bit_array(first), second)
-}
-
-/// Appends a bit array to the end of a builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.append` instead.")
-pub fn append(to first: BytesTree, suffix second: BitArray) -> BytesTree {
- bytes_tree.append_tree(first, bytes_tree.from_bit_array(second))
-}
-
-/// Prepends a builder onto the start of another.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.prepend_tree` instead.")
-pub fn prepend_builder(
- to second: BytesTree,
- prefix first: BytesTree,
-) -> BytesTree {
- bytes_tree.append_tree(first, second)
-}
-
-/// Appends a builder onto the end of another.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.append_tree` instead.")
-@external(erlang, "gleam_stdlib", "iodata_append")
-pub fn append_builder(
- to first: BytesTree,
- suffix second: BytesTree,
-) -> BytesTree {
- bytes_tree.append_tree(first, second)
-}
-
-/// Prepends a string onto the start of a builder.
-///
-/// Runs in constant time when running on Erlang.
-/// Runs in linear time with the length of the string otherwise.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.prepend_string` instead.")
-pub fn prepend_string(to second: BytesTree, prefix first: String) -> BytesTree {
- bytes_tree.append_tree(bytes_tree.from_string(first), second)
-}
-
-/// Appends a string onto the end of a builder.
-///
-/// Runs in constant time when running on Erlang.
-/// Runs in linear time with the length of the string otherwise.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.append_string` instead.")
-pub fn append_string(to first: BytesTree, suffix second: String) -> BytesTree {
- bytes_tree.append_tree(first, bytes_tree.from_string(second))
-}
-
-/// Joins a list of builders into a single builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.concat` instead.")
-@external(erlang, "gleam_stdlib", "identity")
-pub fn concat(builders: List(BytesTree)) -> BytesTree {
- bytes_tree.concat(builders)
-}
-
-/// Joins a list of bit arrays into a single builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.concat_bit_arrays` instead.")
-@external(erlang, "gleam_stdlib", "identity")
-pub fn concat_bit_arrays(bits: List(BitArray)) -> BytesTree {
- bytes_tree.concat_bit_arrays(bits)
-}
-
-/// Creates a new builder from a string.
-///
-/// Runs in constant time when running on Erlang.
-/// Runs in linear time otherwise.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.from_string` instead.")
-@external(erlang, "gleam_stdlib", "wrap_list")
-pub fn from_string(string: String) -> BytesTree {
- bytes_tree.from_string(string)
-}
-
-/// Creates a new builder from a string builder.
-///
-/// Runs in constant time when running on Erlang.
-/// Runs in linear time otherwise.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.from_string_tree` instead.")
-@external(erlang, "gleam_stdlib", "wrap_list")
-pub fn from_string_builder(builder: StringTree) -> BytesTree {
- bytes_tree.from_string_tree(builder)
-}
-
-/// Creates a new builder from a bit array.
-///
-/// Runs in constant time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.from_bit_array` instead.")
-@external(erlang, "gleam_stdlib", "wrap_list")
-pub fn from_bit_array(bits: BitArray) -> BytesTree {
- bytes_tree.from_bit_array(bits)
-}
-
-/// Turns an builder into a bit array.
-///
-/// Runs in linear time.
-///
-/// When running on Erlang this function is implemented natively by the
-/// virtual machine and is highly optimised.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.to_bit_array` instead.")
-@external(erlang, "erlang", "list_to_bitstring")
-pub fn to_bit_array(builder: BytesTree) -> BitArray {
- bytes_tree.to_bit_array(builder)
-}
-
-/// Returns the size of the builder's content in bytes.
-///
-/// Runs in linear time.
-///
-@deprecated("The `bytes_builder` module has been deprecated, use `bytes_tree.byte_size` instead.")
-@external(erlang, "erlang", "iolist_size")
-pub fn byte_size(builder: BytesTree) -> Int {
- bytes_tree.byte_size(builder)
-}
diff --git a/src/gleam/string_builder.gleam b/src/gleam/string_builder.gleam
deleted file mode 100644
index bf89bd3..0000000
--- a/src/gleam/string_builder.gleam
+++ /dev/null
@@ -1,212 +0,0 @@
-import gleam/string_tree.{type StringTree}
-
-/// `StringBuilder` is a type used for efficiently building text content to be
-/// written to a file or a socket. Internally it is represented as tree so to
-/// append or prepend to a string builder is a constant time operation that
-/// allocates a new node in the tree without copying any of the content. When
-/// writing to an output stream the tree is traversed and the content is sent
-/// directly rather than copying it into a single buffer beforehand.
-///
-/// On Erlang this type is compatible with Erlang's iodata. On JavaScript this
-/// type is compatible with normal strings.
-///
-/// The BEAM virtual machine has an optimisation for appending strings, where it
-/// will mutate the string buffer when safe to do so, so if you are looking to
-/// build a string through appending many small strings then you may get better
-/// performance by not using a string builder. Always benchmark your performance
-/// sensitive code.
-///
-@deprecated("The `string_builder` module has been deprecated, use the `string_tree.StringTree` type instead.")
-pub type StringBuilder =
- StringTree
-
-/// Create an empty `StringBuilder`. Useful as the start of a pipe chaining many
-/// builders together.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.new` instead.")
-pub fn new() -> StringTree {
- string_tree.from_strings([])
-}
-
-/// Prepends a `String` onto the start of some `StringBuilder`.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.prepend` instead.")
-pub fn prepend(to builder: StringTree, prefix prefix: String) -> StringTree {
- string_tree.append_tree(string_tree.from_string(prefix), builder)
-}
-
-/// Appends a `String` onto the end of some `StringBuilder`.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.append` instead.")
-pub fn append(to builder: StringTree, suffix second: String) -> StringTree {
- string_tree.append_tree(builder, string_tree.from_string(second))
-}
-
-/// Prepends some `StringBuilder` onto the start of another.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.prepend_tree` instead.")
-pub fn prepend_builder(
- to builder: StringTree,
- prefix prefix: StringTree,
-) -> StringTree {
- string_tree.prepend_tree(builder, prefix)
-}
-
-/// Appends some `StringBuilder` onto the end of another.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.append_tree` instead.")
-pub fn append_builder(
- to builder: StringTree,
- suffix suffix: StringTree,
-) -> StringTree {
- string_tree.append_tree(builder, suffix)
-}
-
-/// Converts a list of strings into a builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.from_strings` instead.")
-pub fn from_strings(strings: List(String)) -> StringTree {
- string_tree.from_strings(strings)
-}
-
-/// Joins a list of builders into a single builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.concat` instead.")
-pub fn concat(builders: List(StringTree)) -> StringTree {
- string_tree.concat(builders)
-}
-
-/// Converts a string into a builder.
-///
-/// Runs in constant time.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.from_string` instead.")
-pub fn from_string(string: String) -> StringTree {
- string_tree.from_string(string)
-}
-
-/// Turns an `StringBuilder` into a `String`
-///
-/// This function is implemented natively by the virtual machine and is highly
-/// optimised.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.to_string` instead.")
-pub fn to_string(builder: StringTree) -> String {
- string_tree.to_string(builder)
-}
-
-/// Returns the size of the `StringBuilder` in bytes.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.byte_size` instead.")
-pub fn byte_size(builder: StringTree) -> Int {
- string_tree.byte_size(builder)
-}
-
-/// Joins the given builders into a new builder separated with the given string
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.join` instead.")
-pub fn join(builders: List(StringTree), with sep: String) -> StringTree {
- string_tree.join(builders, sep)
-}
-
-/// Converts a builder to a new builder where the contents have been
-/// lowercased.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.lowercase` instead.")
-pub fn lowercase(builder: StringTree) -> StringTree {
- string_tree.lowercase(builder)
-}
-
-/// Converts a builder to a new builder where the contents have been
-/// uppercased.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.uppercase` instead.")
-pub fn uppercase(builder: StringTree) -> StringTree {
- string_tree.uppercase(builder)
-}
-
-/// Converts a builder to a new builder with the contents reversed.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.reverse` instead.")
-pub fn reverse(builder: StringTree) -> StringTree {
- string_tree.reverse(builder)
-}
-
-/// Splits a builder on a given pattern into a list of builders.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.split` instead.")
-pub fn split(iodata: StringTree, on pattern: String) -> List(StringTree) {
- string_tree.split(iodata, pattern)
-}
-
-/// Replaces all instances of a pattern with a given string substitute.
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.replace` instead.")
-@external(erlang, "gleam_stdlib", "string_replace")
-@external(javascript, "../gleam_stdlib.mjs", "string_replace")
-pub fn replace(
- in builder: StringTree,
- each pattern: String,
- with substitute: String,
-) -> StringTree
-
-/// Compares two builders to determine if they have the same textual content.
-///
-/// Comparing two iodata using the `==` operator may return `False` even if they
-/// have the same content as they may have been build in different ways, so
-/// using this function is often preferred.
-///
-/// ## Examples
-///
-/// ```gleam
-/// from_strings(["a", "b"]) == from_string("ab")
-/// // -> False
-/// ```
-///
-/// ```gleam
-/// is_equal(from_strings(["a", "b"]), from_string("ab"))
-/// // -> True
-/// ```
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.is_equal` instead.")
-@external(erlang, "string", "equal")
-pub fn is_equal(a: StringTree, b: StringTree) -> Bool {
- a == b
-}
-
-/// Inspects a builder to determine if it is equivalent to an empty string.
-///
-/// ## Examples
-///
-/// ```gleam
-/// from_string("ok") |> is_empty
-/// // -> False
-/// ```
-///
-/// ```gleam
-/// from_string("") |> is_empty
-/// // -> True
-/// ```
-///
-/// ```gleam
-/// from_strings([]) |> is_empty
-/// // -> True
-/// ```
-///
-@deprecated("The `string_builder` module has been deprecated, use `string_tree.is_empty` instead.")
-@external(erlang, "string", "is_empty")
-pub fn is_empty(builder: StringTree) -> Bool {
- string_tree.from_string("") == builder
-}