d8e4f39aa8
GSList doesn't seem the best choice here. It's benefits are that it's relatively convenient to use (albeit not very efficient) and that an empty list requires only the pointer to the list's head. But for non-empty list, we need to allocate GSList elements. We can do better, by writing more code. I think it's worth optimizing GObject, at the expense of a bit(?) more complicated code. The complicated code is still entirely self-contained, so unless you review WeakRefData usage, it doesn't need to bother you. Note that this can be easily measure to be a bit faster. But I think the more important part is to safe some allocations. Often objects are long-lived, and the GWeakRef will be tracked for a long time. It is interesting, to optimize the memory usage of that. - if the list only contains one weak reference, it's interned/embedded in WeakRefData.list.one. Otherwise, an array is allocated and tracked at WeakRefData.list.many. - when the buffer grows, we double the size. When the buffer shrinks, we reallocate to 50% when 75% are empty. When the buffer shrinks to length 1, we free it (so that "list.one" is always used with a length of 1). That means, at worst case we waste 75% of the allocated buffer, which is a choice in the hope that future weak references will be registered, and that this is a suitable strategy. - on architectures like x86_68, does this not increase the size of WeakRefData. Also, the number of weak-refs is now limited to 65535, and now an assertion fails when you try to register more than that. But note that the internal tracking just uses a linear search, so you really don't want to register thousands of weak references on an object. If you do that, the current implementation is not suitable anyway and you must rethink your approach. Nor does it make sense to optimize the implementation for such a use case. Instead, the implementation is optimized for a few (one!) weak reference per object. |
||
---|---|---|
.gitlab-ci | ||
.reuse | ||
docs | ||
fuzzing | ||
gio | ||
girepository | ||
glib | ||
gmodule | ||
gobject | ||
gthread | ||
LICENSES | ||
m4macros | ||
po | ||
subprojects | ||
tests | ||
tools | ||
.clang-format | ||
.dir-locals.el | ||
.editorconfig | ||
.gitignore | ||
.gitlab-ci.yml | ||
.gitmodules | ||
.lcovrc | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
COPYING | ||
glib.doap | ||
INSTALL.md | ||
meson_options.txt | ||
meson.build | ||
NEWS | ||
README.md | ||
SECURITY.md |
GLib
GLib is the low-level core library that forms the basis for projects such as GTK and GNOME. It provides data structure handling for C, portability wrappers, and interfaces for such runtime functionality as an event loop, threads, dynamic loading, and an object system.
The official download locations are: https://download.gnome.org/sources/glib
The official web site is: https://www.gtk.org/
Installation
See the file ‘INSTALL.md’. There is separate and more in-depth documentation for building GLib on Windows.
Supported versions
Upstream GLib only supports the most recent stable release series, the previous stable release series, and the current development release series. All older versions are not supported upstream and may contain bugs, some of which may be exploitable security vulnerabilities.
See SECURITY.md for more details.
Documentation
API documentation is available online for GLib for the:
Discussion
If you have a question about how to use GLib, seek help on GNOME’s Discourse
instance. Alternatively, ask a question
on StackOverflow and tag it glib
.
Reporting bugs
Bugs should be reported to the GNOME issue tracking system. You will need to create an account for yourself. You may also submit bugs by e-mail (without an account) by e-mailing incoming+gnome-glib-658-issue-@gitlab.gnome.org, but this will give you a degraded experience.
Bugs are for reporting problems in GLib itself, not for asking questions about how to use it. To ask questions, use one of our discussion forums.
In bug reports please include:
- Information about your system. For instance:
- What operating system and version
- For Linux, what version of the C library
- And anything else you think is relevant.
- How to reproduce the bug.
- If you can reproduce it with one of the test programs that are built
in the
tests/
subdirectory, that will be most convenient. Otherwise, please include a short test program that exhibits the behavior. As a last resort, you can also provide a pointer to a larger piece of software that can be downloaded.
- If you can reproduce it with one of the test programs that are built
in the
- If the bug was a crash, the exact text that was printed out when the crash occurred.
- Further information such as stack traces may be useful, but is not necessary.
Contributing to GLib
Please follow the contribution guide to know how to start contributing to GLib.
Patches should be submitted as merge requests to gitlab.gnome.org. If the patch fixes an existing issue, please refer to the issue in your commit message with the following notation (for issue 123):
Closes: #123
Otherwise, create a new merge request that introduces the change. Filing a separate issue is not required.