Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103746 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12626 invoked from network); 15 Jan 2019 16:06:44 -0000 Received: from unknown (HELO mail-io1-f43.google.com) (209.85.166.43) by pb1.pair.com with SMTP; 15 Jan 2019 16:06:44 -0000 Received: by mail-io1-f43.google.com with SMTP id l14so1912057ioj.5 for ; Tue, 15 Jan 2019 04:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JfVID31doTRZUgkR4OtYSo6dac+XvdIM+WWxRhAJ2WM=; b=GrDAYAAPzmTcBSQ9g2VtuMbBR0/U7FL9WpUknm8JnPNhXPnLEPFGnD4lK341TTUYNa VAsLcQEdcec4bpx75PWgZHcLG5jptbs1fSDHFHZnlHyzE6FpiqwzONyTYvGpT+cPsrs5 2ar99rJ8vTtvplRKzzXgT2FUUPvL+q1e73UgH+Opmq7HE9VW8vhBNyVZmCijb30vEyqU iQgkpDHGBqehD8Ivz9YqmpD3AWWBIwQr/YmYUS+UjCUsljMRdmumYO0SLpbABiCH+XvM /sVnhwTCkuu3QF0nOGgJKAWP/DdTe5UugFsr+3BZslWQmYB6MpFeAEeF8+K/g0QjKkZh sBKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JfVID31doTRZUgkR4OtYSo6dac+XvdIM+WWxRhAJ2WM=; b=um9jW+hfNjZQvR3kE5eb+wX9gDD6lpzli159am0VSdGKWbcXtAXCsRPC746NpRdXcx Og9PA4u1wShkREOu1j6XbiZk65m+KfR5uYQVffZCE/PXxLuZzxmIhMlcu2fuEnhNlqw6 vP0YcJFVnJCNbaBX51+HD4UnuwjGwJjq32VgxSYfDNjvvq3VbFmKKL/EgFee5S9ntPuN 0eHaJHB4qAcYIt9lVq13bVa2/qBaP3Eha7Uqjug2xQCaavc5flxUyppxxa2i2HMYKHzB qWTH3pUsQkbV04DiopYu4ipTqN7HB2rJMEJrjBtohEjNMkZhz2pxqyHghJjaVgDIzFLa xSoA== X-Gm-Message-State: AJcUukdfrNUR8gXn8lzlF+QtlZ40ztuNLcWGcsSbv73MFddpMrd7B9ag tNEtqhQpb/AGH76N9kjrEyA4xAY92on4Xe9fwyA= X-Google-Smtp-Source: ALg8bN6mkIrouGAEczU2SqaGxHPX668Mb9LxRqmqGPT+EglkimgW9phr7kCadCHpU5ZRNR6o0BpkhIe6V1SZxZCShoc= X-Received: by 2002:a5d:834e:: with SMTP id q14mr887236ior.258.1547556157197; Tue, 15 Jan 2019 04:42:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 15 Jan 2019 13:42:21 +0100 Message-ID: To: Nicolas Grekas Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000051481057f7e7fd4" Subject: Re: [PHP-DEV] [RFC] Reflection for references From: nikita.ppv@gmail.com (Nikita Popov) --000000000000051481057f7e7fd4 Content-Type: text/plain; charset="UTF-8" On Tue, Jan 15, 2019 at 1:09 PM Nicolas Grekas wrote: > About using "int" as return type for getId(): > > > * Can the `getId()` return type be restricted to either `int` or >> > `string`? Why is it a union type right now? Technical limitation? >> >> To allow changes in the future. The real return value here is an int, but >> the size increase due to hashing makes it a string. If we find a way to >> avoid that (or decided that we don't care about leaking addresses), we >> could change this to a (faster) int-based API. >> > > spl_object_hash() uses a XOR to hide internal addresses - so they're > already "leaking". > we also added spl_object_id() which proved much better in term of memory > usage - not only CPU. > > Mixing both arguments/approaches, what about returning a XORed int? Are we > OK with that? It'd be a welcome storage/CPU optimization from my pov. > A XORed int is not much better than returning the address directly -- it will scramble the base address, but for example not the offsets between the references (if the XOR key is the same). If people think that this is good enough for us, then of course it's better to go with the int for performance reasons. I've picked the sha1 here to be conservative. How performance critical is this API? Nikita --000000000000051481057f7e7fd4--