Re: [Vala] How to check if string is empty
- From: Ulink <ulink gmx at>
- To: vala-list gnome org
- Subject: Re: [Vala] How to check if string is empty
- Date: Tue, 17 Jan 2017 15:03:31 +0100
Am 2017-01-17 um 12:09 schrieb rastersoft:
That's true for the first one, but the second is as fast as str[0] == 0,
because as soon as one byte doesn't fit, the function ends.
You are right, because str=="" indeed calls g_strcmp0(), but
str[0]=='\0' calls string_get() which seems not faster that g_strcmp0().
So the fastest (C-like) solution would be:
bool is_null_or_empty3 (string? str)
{
return str == null || *(char*)str == '\0';
}
But it's ugly ;-)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]