<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libgit2.git/src/util.c, branch ethomson/treebuilder_write</title>
<subtitle>github.com: libgit2/libgit2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/'/>
<entry>
<title>Make git__strntol64() ~70%* faster</title>
<updated>2020-12-13T01:50:58+00:00</updated>
<author>
<name>lhchavez</name>
<email>lhchavez@lhchavez.com</email>
</author>
<published>2020-12-13T00:51:15+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=e99e833f4808e027de8e984b9b99544ca41e28e2'/>
<id>e99e833f4808e027de8e984b9b99544ca41e28e2</id>
<content type='text'>
This change uses compiler intrinsics to detect overflows instead of
using divisions to detect potential overflow. This makes the code faster
and makes it easier to read as a bonus side-effect!

Some of the things this quickens:

* Config parsing.
* Tree parsing.
* Smart protocol negotiation.

\* Measured by running `libgit2_clar` with `-fno-optimize-sibling-calls
-fno-omit-frame-pointer` under `perf(1)`:

```shell
$ perf diff --symbols=git__strntol64 --compute=ratio \
  --percentage=absolute baseline.data perf.data
\# Event 'cycles'
\#
\# Baseline           Ratio  Shared Object
\# ........  ..............  .............
\#
     0.25%        0.321836  libgit2_clar
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change uses compiler intrinsics to detect overflows instead of
using divisions to detect potential overflow. This makes the code faster
and makes it easier to read as a bonus side-effect!

Some of the things this quickens:

* Config parsing.
* Tree parsing.
* Smart protocol negotiation.

\* Measured by running `libgit2_clar` with `-fno-optimize-sibling-calls
-fno-omit-frame-pointer` under `perf(1)`:

```shell
$ perf diff --symbols=git__strntol64 --compute=ratio \
  --percentage=absolute baseline.data perf.data
\# Event 'cycles'
\#
\# Baseline           Ratio  Shared Object
\# ........  ..............  .............
\#
     0.25%        0.321836  libgit2_clar
```
</pre>
</div>
</content>
</entry>
<entry>
<title>win32: provide macros for calling conventions</title>
<updated>2020-12-08T14:50:06+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@microsoft.com</email>
</author>
<published>2020-12-08T14:33:31+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=42d5f11084c67f8c96693bd42b424b0262be3f84'/>
<id>42d5f11084c67f8c96693bd42b424b0262be3f84</id>
<content type='text'>
Provide more clarity for Win32 calling conventions - now that we always
compile to __cdecl on Win32, we'll define that as the the libgit2
calling convention.  Also offer NTAPI (__stdcall) calling conventions
for things that need callbacks from NTAPI code (eg fiber-local storage).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Provide more clarity for Win32 calling conventions - now that we always
compile to __cdecl on Win32, we'll define that as the the libgit2
calling convention.  Also offer NTAPI (__stdcall) calling conventions
for things that need callbacks from NTAPI code (eg fiber-local storage).
</pre>
</div>
</content>
</entry>
<entry>
<title>util: move git_online_cpus into util</title>
<updated>2020-12-06T00:55:35+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2020-12-05T16:08:34+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=9800728a746b872fdd22db9e68bc85ef0c851f27'/>
<id>9800728a746b872fdd22db9e68bc85ef0c851f27</id>
<content type='text'>
The number of CPUs is useful information for creating a thread pool or a
number of workers, but it's not really about threading directly.  Evict
it from the thread file
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The number of CPUs is useful information for creating a thread pool or a
number of workers, but it's not really about threading directly.  Evict
it from the thread file
</pre>
</div>
</content>
</entry>
<entry>
<title>tree-wide: mark local functions as static</title>
<updated>2020-06-09T12:57:06+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2020-06-08T10:40:47+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=a6c9e0b367c4882ab0f8e78bd0ad4ab2904ac377'/>
<id>a6c9e0b367c4882ab0f8e78bd0ad4ab2904ac377</id>
<content type='text'>
We've accumulated quite some functions which are never used outside of
their respective code unit, but which are lacking the `static` keyword.
Add it to reduce their linkage scope and allow the compiler to optimize
better.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We've accumulated quite some functions which are never used outside of
their respective code unit, but which are lacking the `static` keyword.
Add it to reduce their linkage scope and allow the compiler to optimize
better.
</pre>
</div>
</content>
</entry>
<entry>
<title>strarray: move to its own file</title>
<updated>2020-06-01T21:50:28+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2020-05-29T10:21:55+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=a9746b306d32cc2d2bc5d446f6f7ae7c7068ba79'/>
<id>a9746b306d32cc2d2bc5d446f6f7ae7c7068ba79</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>git__hexdump: better mimic `hexdump -C`</title>
<updated>2020-04-01T20:59:37+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2020-03-01T18:34:15+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=5d37128db155d0688d7e8391a9eb5fe1d32a844f'/>
<id>5d37128db155d0688d7e8391a9eb5fe1d32a844f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>util: hide helper qsort code to silence unused functions warning</title>
<updated>2019-10-13T11:54:04+00:00</updated>
<author>
<name>Etienne Samson</name>
<email>samson.etienne@gmail.com</email>
</author>
<published>2019-09-21T06:47:01+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=aa234ac02d69e84d7fedc3fc6d56ac56760b4169'/>
<id>aa234ac02d69e84d7fedc3fc6d56ac56760b4169</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>util: do not perform allocations in insertsort</title>
<updated>2019-08-23T10:54:02+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-08-08T09:52:54+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=8cbef12d45db531933e7795820f116a07a21f48b'/>
<id>8cbef12d45db531933e7795820f116a07a21f48b</id>
<content type='text'>
Our hand-rolled fallback sorting function `git__insertsort_r` does an
in-place sort of the given array. As elements may not necessarily be
pointers, it needs a way of swapping two values of arbitrary size, which
is currently implemented by allocating a temporary buffer of the
element's size. This is problematic, though, as the emulated `qsort`
interface doesn't provide any return values and thus cannot signal an
error if allocation of that temporary buffer has failed.

Convert the function to swap via a temporary buffer allocated on the
stack. Like this, it can `memcpy` contents of both elements in small
batches without requiring a heap allocation. The buffer size has been
chosen such that in most cases, a single iteration of copying will
suffice. Most importantly, it can fully contain `git_oid` structures and
pointers.

Add a bunch of tests for the `git__qsort_r` interface to verify nothing
breaks. Furthermore, this removes the declaration of `git__insertsort_r`
and makes it static as it is not used anywhere else.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Our hand-rolled fallback sorting function `git__insertsort_r` does an
in-place sort of the given array. As elements may not necessarily be
pointers, it needs a way of swapping two values of arbitrary size, which
is currently implemented by allocating a temporary buffer of the
element's size. This is problematic, though, as the emulated `qsort`
interface doesn't provide any return values and thus cannot signal an
error if allocation of that temporary buffer has failed.

Convert the function to swap via a temporary buffer allocated on the
stack. Like this, it can `memcpy` contents of both elements in small
batches without requiring a heap allocation. The buffer size has been
chosen such that in most cases, a single iteration of copying will
suffice. Most importantly, it can fully contain `git_oid` structures and
pointers.

Add a bunch of tests for the `git__qsort_r` interface to verify nothing
breaks. Furthermore, this removes the declaration of `git__insertsort_r`
and makes it static as it is not used anywhere else.
</pre>
</div>
</content>
</entry>
<entry>
<title>strtol: cast error message length to int</title>
<updated>2019-06-24T14:00:41+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-05-21T13:15:58+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=db6b8f7db1973ad874a8ec1d147ad8e98e65d9cb'/>
<id>db6b8f7db1973ad874a8ec1d147ad8e98e65d9cb</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>utf8: use size_t for length of buffer</title>
<updated>2019-06-24T14:00:41+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-05-21T11:50:46+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=ad6f2153ed06405477704f4f0eefe08ab0c0d807'/>
<id>ad6f2153ed06405477704f4f0eefe08ab0c0d807</id>
<content type='text'>
The `git__utf8_charlen` now takes `size_t` as the buffer length, since
it contains the full length of the buffer at the current position.  It
now returns `-1` in all cases where utf8 codepoints are invalid, since
callers only care about a valid length of a sequence of codepoints, or
if the current position is not valid utf8.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The `git__utf8_charlen` now takes `size_t` as the buffer length, since
it contains the full length of the buffer at the current position.  It
now returns `-1` in all cases where utf8 codepoints are invalid, since
callers only care about a valid length of a sequence of codepoints, or
if the current position is not valid utf8.
</pre>
</div>
</content>
</entry>
</feed>
