Commit graph

12233 commits

Author SHA1 Message Date
Nico Weber
4a57cbc98f LibX86: Remove some allocations from Instruction::to_string
Instruction::to_string used to copy a string literal into a String,
and then the String into a StringBuilder. Copy it to the StringBuilder
directly.

No measurable performance benefit, but it's also less code.
2020-08-16 19:38:55 +02:00
thankyouverycool
5558b2cf9f Base: Rename Pebbleton to reflect actual height
And update programs loading it from file.
2020-08-16 19:38:21 +02:00
Nico Weber
f025204dfe disasm: For ELF inputs, pass an ELFSymbolProvider to disassembler
This lets disasm output contain the symbol names of call and jump
destinations:

    8048111:	e8 88 38 01 00       	call   805b99e <__cxa_atexit>
    ...
    8048150:	74 15                	je     8048167 <_start+0x4c>

The latter (the symbol of the current function with an offset) is
arguably more distracting than useful because you usually want to look
at the instruction at the absolute offset in this case, but the former
is very nice to have.

For reasons I do not understand, this cuts the time to run
`disasm /bin/id` in half, from ~1s to ~0.5s.
2020-08-16 19:37:58 +02:00
Nico Weber
fd73de684e X86+Profiler+UserspaceEmulator: Deduplicate ELFSymbolProvider to LibX86
From a layering perspective, it's maybe a bit surprising that the
X86::SymbolProvider implementation also lives in LibX86, but since
everything depends on LibELF via LibC, and since all current
LibX86-based disassemblers want to use ELFSymbolProvider, it makes
some amount of sense to put it there.
2020-08-16 19:37:58 +02:00
Andreas Kling
d396766058 LibGUI: Require a model pointer for ModelIndex::is_valid()
This was not an issue anywhere in practice, but let's make it part of
the definition of a valid model index.
2020-08-16 16:44:09 +02:00
Andreas Kling
a66e55ec64 LibGUI: Make SortingProxyModel clear view selections aggressively
When invalidating all indexes, tell all attached views to just wipe
their selections. This is the best we can do for now.
2020-08-16 16:44:09 +02:00
Andreas Kling
9102b624ac LibGUI+DevTools+Applications: Use ModelIndex::data() in many places
This way you don't have to keep track of which model it came from.
2020-08-16 16:44:09 +02:00
Andreas Kling
96f98b1fc9 LibGUI: Simplify TableCellPaintingDelegate API slightly
No need to pass the Model *and* a ModelIndex, the index knows which
model it belongs to anyway.
2020-08-16 16:44:09 +02:00
Andreas Kling
f882424869 LibGUI: Add ModelIndex::data(ModelRole)
This is a convenience API that makes accessing model data easier.
2020-08-16 16:44:09 +02:00
Andreas Kling
a1e381a0f8 LibGUI: Move GUI::Model::Role to GUI::ModelRole
This is preparation for using ModelRole in the ModelIndex API.
2020-08-16 16:44:09 +02:00
Andreas Kling
f6d7204689 LibGUI: Enable switching FilePicker into columns view mode :^) 2020-08-16 16:44:09 +02:00
Andreas Kling
4c23e75d2f LibGUI: Enable using a ColumnsView inside MultiView :^)
Now that SortingProxyModel has greatly improved support for hierarchies
we can enable this without crashing.
2020-08-16 16:44:09 +02:00
Andreas Kling
b9ae937279 SystemMonitor: Invalidate ProcessModel indexes when necessary
If the process table grows or shrinks, we need to invalidate all the
ProcessModel indexes. This is not great, but it's the most precise
invalidation we can do at the moment.
2020-08-16 16:44:09 +02:00
Andreas Kling
17992fbab7 LibGUI: Resort SortingProxyModel when source invalidates if possible
If the source model invalidates with indexes still good, we can simply
resort the proxy's mappings.
2020-08-16 16:44:09 +02:00
Andreas Kling
6715b696fa LibGUI: Maintain selections across SortingProxyModel resorts
Now that we sort models imperatively, it's easy to preserve any
view selection across a local (same-parent) resort.
2020-08-16 16:44:09 +02:00
Andreas Kling
e1ed71ef9e LibGUI: Make model sorting imperative and move order to AbstractView
Instead of SortingProxyModel having a column+order, we move that state
to AbstractView. When you click on a column header, the view tells the
model to resort the relevant column with the new order.

This is implemented in SortingProxyModel by simply walking all the
reified source/proxy mappings and resorting their row indexes.
2020-08-16 16:44:09 +02:00
Andreas Kling
370624bc37 Meta: Actually exclude the Build/ directory from QtCreator refresh 2020-08-16 16:44:09 +02:00
Andreas Kling
7b110fad56 FileManager: Use one SortingProxyModel for all DirectoryView subviews
This removes one major source of confusion in DirectoryView. It's still
weird that we mix sorting model indexes with filesystem model indexes
a bit willy-nilly but we'll improve that separately.
2020-08-16 16:44:09 +02:00
Andreas Kling
8c8281de4e LibGUI: Make SortingProxyModel support hierarchical models
We now create multiple levels of internal mappings between source
and proxy indexes, to support tree models.

This breaks selection update after resort, which we'll have to
deal with somehow.
2020-08-16 16:44:09 +02:00
Andreas Kling
05dd9e5bfb LibGUI: Virtualize SortingProxyModel comparator
This patch adds SortingProxyModel::less_than(ModelIndex, ModelIndex)
which is now used to implement the sort order. This allows you to
subclass SortingProxyModel if you want to tweak how sorting works.

Get rid of the awkward case sensitivity logic in SortingProxyModel
since that can now be done outside. Turns out nobody was actually
using it anyway, but it seems like something we will want to do
in the future someday.
2020-08-16 16:44:09 +02:00
Andreas Kling
b503f74d25 LibCrypto: Fix MB => MiB build issue 2020-08-16 16:44:09 +02:00
Linus Groh
55bd54f91f LibGUI: Don't center dialog within parent if window is not visible
Windows have an initial off-screen rect, so when a dialog is created and
shown before its parent window, in which it is centered, it would be
invisible to the user.

Fixes #3172.
2020-08-16 16:37:39 +02:00
Tibor Nagy
115c124a77 Chess: Add the 'retro' piece set 2020-08-16 16:36:18 +02:00
Ben Wiederhake
b7589ff4b6 LibCrypto: Move large functions to cpp file
If they use up so much stack space, contain (sometimes several) loops, and take
a noticable amount of time anyway, then 'inline' is probably going to be ignored
by the compiler anyway.
2020-08-16 16:35:23 +02:00
Ben Wiederhake
bbed5b99fd LibCrypto: Fix random generation and primality tests
It was quite silly that LibCrypto thought that 30! is a prime number! :P
2020-08-16 16:35:23 +02:00
Ben Wiederhake
67b24cb3a6 LibCrypto: Document word order (endianness) of bigint 2020-08-16 16:35:23 +02:00
Ben Wiederhake
d33e3b7d8a LibCrypto: Fix random number generation 2020-08-16 16:35:23 +02:00
Ben Wiederhake
2e470a4a47 LibCrypto: Demonstrate that primality and random numbers are broken 2020-08-16 16:35:23 +02:00
Nico Weber
b31aa2e918 Kernel: Switch a comment to GiB 2020-08-16 16:33:28 +02:00
Nico Weber
1e2dc736e3 Userland/tt: Switch to MiB 2020-08-16 16:33:28 +02:00
Nico Weber
af96cfe9ef SystemMonitor: Move memory graph caption from KB to KiB
This changes the graph caption from KB to KiB, but it keeps just "K"
instead of "KiB" for all the numbers in columns in the table, since "K"
is fairly well-established as abbreviation of "KiB" (the SI prefix is
lower-case), and space is at a premium here.
2020-08-16 16:33:28 +02:00
Nico Weber
43a0ffe54d Userland/allocate: Switch to KiB/MiB 2020-08-16 16:33:28 +02:00
Nico Weber
f47dbb6a58 AK: Use IEC prefixes in human_readable_format
Windows uses "KB", "MB", "GB" as powers of two.
macOS uses "kB", "MB", "GB" as powers of ten.

"k", "M", "G" are standard SI prefixes that normally refer to powers of
ten.

The IEC introduced "KiB", "MiB", "GiB" to unambiguously refer to
powers of two. It admittedly hasn't caught on that much, but it
does have the advantage that it's unabigious what it means.
So let's use it for user-visible sizes in SerenityOS.

(Linux does all of the above in different places, depending on app and
toolkit.)
2020-08-16 16:33:28 +02:00
Nico Weber
aa97166739 Everywhere: Consolidate human_readable_size() implementations
Let's use the one in AK/NumberFormat.h everywhere.

It has slightly different behavior than some of the copies this
removes, but it's probably nice to have uniform human readable
size outputs across the system.
2020-08-16 16:33:28 +02:00
Nico Weber
430b265cd4 AK: Rename KB, MB, GB to KiB, MiB, GiB
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".

Let's use the correct name, at least in code.

Only changes the name of the constants, no other behavior change.
2020-08-16 16:33:28 +02:00
Muhammad Zahalqa
a68650a7b4
AK: HashTable add a constructor that allows preallocation of capacity + Use in CppLexer. (#3147)
1. Add general utility to get array number of elements.
2. Add Needed API to AK::HashTable
3. Refactor CppLexer initialization
2020-08-16 11:04:00 +02:00
asynts
fc276946fb Refactor: Use ReadonlyBytes instead of const ReadonlyBytes&. 2020-08-15 21:21:18 +02:00
asynts
fff581cd72 AK: Rename span() to bytes() when appropriate.
I originally defined the bytes() method for the String class, because it
made it obvious that it's a span of bytes instead of span of characters.

This commit makes this more consistent by defining a bytes() method when
the type of the span is known to be u8.

Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and
such.
2020-08-15 21:21:18 +02:00
asynts
525d51bbb5 AK: Add slice() overload to Span. 2020-08-15 21:21:18 +02:00
asynts
36080c5964 AK: Add fill() method to Span. 2020-08-15 21:21:18 +02:00
asynts
78849bbb48 AK: Add copy_to() and move_to() methods to AK::Span. 2020-08-15 21:21:18 +02:00
asynts
8e7dfebf11 AK: Add bytes() method to FixedArray. 2020-08-15 21:21:18 +02:00
asynts
d4fe63d2ce AK: Remove incorrect static assert in Span.h.
This assertion was added to prevent accitentally using stuff like
Span<int*> instead of Span<int>. But there can be spans of pointers.
2020-08-15 21:21:18 +02:00
Peter Elliott
d90f8abe9d Chess: Add new ways to draw.
new ways:
Insufficent material
Threefold/Fivefold repitition
50 move/75 move rule
2020-08-15 20:54:02 +02:00
Peter Elliott
9a817270e8 Chess: Add the 'stelar7' piece set
Co-authored-by: stelar7 <dudedbz@gmail.com>
2020-08-15 20:54:02 +02:00
Peter Elliott
abd1f7e563 Chess: Add pawn promotion to any piece 2020-08-15 20:54:02 +02:00
Peter Elliott
9d40472721 Chess: Add En-passant 2020-08-15 20:54:02 +02:00
Peter Elliott
e91542a3cf Chess: Add menu options for setting board theme and piece set 2020-08-15 20:54:02 +02:00
Peter Elliott
7b71f4759f Chess: Highlight last move 2020-08-15 20:54:02 +02:00
Peter Elliott
f2c1782d86 Chess: Add win/draw conditions, and display them. 2020-08-15 20:54:02 +02:00