Commit Graph

24 Commits

Author SHA1 Message Date
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Lenny Maiorani
ea58b8d927 Libraries: Use default constructors/destructors in LibCore
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-10 18:04:26 -08:00
Sam Atkins
45cf40653a Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr
Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
2022-01-24 22:36:09 +01:00
Sahan Fernando
2c43eaa50c LibCore: Add support for range-based for loops on LineIterators 2021-12-12 14:06:38 +03:30
Sahan Fernando
6d948c1a92 LibCore: Fix bug in IODevice::LineIterator causing skipped lines 2021-12-12 14:06:38 +03:30
Arne Elster
cdaa179eeb LibCore: Fix relative seeking in IODevice
The recently introduced read buffer in IODevice broke relative seeking.
The amount of data in the buffer wouldn't get taken into account.
2021-11-30 10:51:10 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Karol Kosek
2a461704c4 LibCore: Display the correct allocation size in the debug line
Someone named Karol forgot to update this line in #10205..
2021-10-09 23:30:12 +02:00
Nico Weber
b8dc3661ac Libraries: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Ali Mohammad Pur
e112e6620f LibCore: Allow reads smaller than the buffered data size in IODevice
This restriction doesn't make much sense, a user should be free to
consume the buffered data with as small a max_size as they desire.
This fixes a possible RequestServer spin when talking to HTTP servers.
2021-10-04 11:00:44 +02:00
Karol Kosek
484f6a7cfa LibCore: Buffer small byte reads
Prior this change, if you had a program which frequently reads small
amount of bytes, then it would constantly fire up syscalls.

This patch sets that the minimum size that is passed to the read syscall
is 1024 and then it saves these additional bytes in a buffer for next
reads, which greatly improves the cpu usage on such cases.

In other words: reading flacs is now very efficient.
2021-09-27 16:31:28 +02:00
Karol Kosek
48a925b1d2 LibCore: Add optional custom read size argument in populate_read_buffer
This is a small preparation so IODevice::read() can use it in the next
commit.
2021-09-27 16:31:28 +02:00
Ali Mohammad Pur
97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Gunnar Beutner
d8b5fa9dfe AK: Remove the public ByteBuffer::trim method
This removes the public trim() method because it is no longer
necessary. Callers can instead use resize().
2021-05-31 14:49:00 +04:30
r-paiva
943f4eb287 LibCore: Let IODevice::can_read_line() buffer until \n or EOF
If a line was larger than 1024 bytes or the file ended without a
newline character, can_read_line would return false.

IODevice::can_read_line() now reads until a newline is found or
EOF is reached.

fixes #5907
2021-05-20 23:53:06 +02:00
Gunnar Beutner
53d0150827 AK+Userland: Remove nullability feature for the ByteBuffer type
Nobody seems to use this particular feature, in fact there were some
bugs which were uncovered by removing operator bool.
2021-05-16 17:49:42 +02:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Andreas Kling
406c876fce LibCore: Remove Core::IODevice::printf() 2021-05-07 22:11:50 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
e5318d51e6 LibCore: Remove the barely-used Core::safe_syscall()
This was a helper that would call a syscall repeatedly until it either
succeeded or failed with a non-EINTR error.

It was only used in two places, so I don't think we need this helper.
2021-04-21 23:49:01 +02:00
Andreas Kling
2146d22432 LibCore: Save errno before it gets clobbered in Core::IODevice::write() 2021-04-10 22:31:29 +02:00
Andreas Kling
c1dd5553a8 LibCore: Convert dbgprintf() => dbgln() 2021-02-17 15:40:52 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00