From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: sqlite3 Date: Mon, 06 Dec 2021 22:29:48 +0200 Message-ID: <83tuflzdc3.fsf@gnu.org> References: <87tufmjyai.fsf@gnus.org> <87sfv5ljxn.fsf@gnus.org> <8735n5leza.fsf@gnus.org> <835ys11pxy.fsf@gnu.org> <87pmq9jyv1.fsf@gnus.org> <831r2p1or2.fsf@gnu.org> <87czm9jxjd.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18800"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 06 21:30:39 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1muKdB-0004fO-Pe for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Dec 2021 21:30:37 +0100 Original-Received: from localhost ([::1]:40728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muKdA-0006WH-Gi for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Dec 2021 15:30:36 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muKcQ-0005hS-7T for emacs-devel@gnu.org; Mon, 06 Dec 2021 15:29:50 -0500 Original-Received: from [2001:470:142:3::e] (port=40816 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muKcP-00019X-S0; Mon, 06 Dec 2021 15:29:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5QP2glwDV3hkypKY1rpiq3eH3Y9OL68QC2iCmfxyiFc=; b=nC5iMSvEVBgM sT3x+PCFfUO0K9rKXnjk+zgWQBIT1BAFiVYgOVFgLXYmTTItwjufRKmEOxul8dmRqJDQKbkm6PvGJ ZKRCGbiGq+VmQvOQPFowNOxsddguEkvPFV5D7iIhpwF7ZlODJZZL8NXyu3rj4q40ZZs5NsWXGRWzg MQW8yEfcn5oSi6KGMV+Sz2JaxmjoT64ty1mnmrEEiR3V2GHTukju3tZHk4Sxy8D/mPlcFIXk283gS n7DV7lU6cYJkYTZ++2UlMmscYkW2DB+WnvWPbvumNzwQ4Rtfr/D+AVjZTIdQJDcTkoNSoPiRemYIV dFzsI5VuQrOeNyMAMMioHg==; Original-Received: from [87.69.77.57] (port=2153 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muKcP-0000G9-HS; Mon, 06 Dec 2021 15:29:49 -0500 In-Reply-To: <87czm9jxjd.fsf@gnus.org> (message from Lars Ingebrigtsen on Mon, 06 Dec 2021 21:20:06 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:281175 Archived-At: > From: Lars Ingebrigtsen > Cc: emacs-devel@gnu.org > Date: Mon, 06 Dec 2021 21:20:06 +0100 > > Eli Zaretskii writes: > > > If we want to do better, we need to call encode_string_utf_8, it > > already has all the infrastructure for this case, including fast > > no-copy operation if everything checks out, and a telltale return > > value if not (so we could signal an error). > > I wasn't sure whether this was true: > > This function is optimized for speed when the input string is > already a valid UTF-8 sequence, i.e. there are neither 8-bit raw > bytes nor any UTF-8 sequences longer than 4 bytes in the string's > contents. ??? This says that if the string is a valid UTF-8, the function will work very fast, so what's the problem? > So I went with the slower, more general code_convert_string_norecord, I think this is overkill. encode_string_utf_8 can be called in a way that it will return the original string if it's valid UTF-8, and return nil if not (in which case you signal an error). It was designed for these situations, so it would be a pity not to use it.