libgee_0_8_la_SOURCES = \
$(libgee_0_8_la_VALASOURCES:.vala=.c) \
+ ../utils/assume.h \
../utils/async.h \
../utils/free.h \
../utils/misc.h \
* Didier 'Ptitjes Villevalois <ptitjes@free.fr>
*/
-using GLib;
+using Gee.Utils.Assume;
/**
* Resizable array implementation of the {@link List} interface.
}
private void shift (int start, int delta) {
+#if !DISABLE_INTERNAL_ASSERTS
assert (start >= 0);
assert (start <= _size);
assert (start >= -delta);
+#else
+ assume (start >= 0);
+ assume (start <= _size);
+ assume (start >= -delta);
+#endif
_items.move (start, start + delta, _size - start);
}
private void grow_if_needed (int new_count) {
+#if !DISABLE_INTERNAL_ASSERTS
assert (new_count >= 0);
+#else
+ assume (new_count >= 0);
+#endif
int minimum_size = _size + new_count;
if (minimum_size > _items.length) {
assert (_index < _list._size);
return _index;
}
-
+
public bool read_only {
get {
return false;
}
}
-
+
public bool valid {
get {
return _index >= 0 && _index < _list._size && ! _removed;
* Didier 'Ptitjes Villevalois <ptitjes@free.fr>
*/
+using Gee.Utils.Assume;
+
/**
* Doubly-linked list implementation of the {@link List} interface.
*
public override int size {
get { return this._size; }
}
-
+
/**
* {@inheritDoc}
*/
assert (index < this._size);
unowned Node<G>? n = this._get_node_at (index);
+#if !DISABLE_INTERNAL_ASSERTS
assert (n != null);
+#endif
return n.data;
}
assert (index < this._size);
unowned Node<G>? n = this._get_node_at (index);
+#if !DISABLE_INTERNAL_ASSERTS
assert (n != null);
+#endif
G element = n.data;
this._remove_node (n);
return element;
--- /dev/null
+/* assume.h
+ *
+ * Copyright (C) 2013 Maciej Piechotka
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Maciej Piechotka <uzytkownik2@gmail.com>
+ */
+#ifndef GEE_UTILS_ASSUME
+#define GEE_UTILS_ASSUME
+
+#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40500
+#define gee_utils_assume(cond) do { if (!(cond)) __builtin_unreachable(); } while (0)
+#elif defined(_MSC_VER)
+#define gee_utils_assume(cond) __assume(cond)
+#else
+#define gee_utils_assume(cond) NULL
+#endif
+
+#endif
namespace Gee {
namespace Utils {
+ namespace Assume {
+ [CCode (cheader_filename = "assume.h", cname = "gee_utils_assume")]
+ public void assume(bool cond);
+ }
namespace Async {
[CCode (cheader_filename = "async.h")]
public async void yield_and_unlock (GLib.Mutex mutex);