System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Overview

Artifact ID: 5700b8bdea49851c69f7ce8b5dc716b484f756c8
Ticket: d3b877c7e0f31d0fcaa20efd8dbaa33b28f42dff
Optimize SQLiteConvert.UTF8ToString for .NET Standard 2.1
User & Date: anonymous 2020-07-04 12:46:52
Changes

  1. foundin changed to: "1.0.113.0"
  2. icomment:
    .NET Standard 2.1 introduced the method `Marshal.PtrToStringUTF8`, which can be used in `SQLiteConvert.UTF8ToString` (similar to using `Marshal.PtrToStringUni` in `SQLite3_UTF16.UTF16ToString`), in order to save allocation of a byte array and to avoid `Marshal.ReadByte()` when using the standard SQLite library.
    
    For example:
    
    ```c#
        public static string UTF8ToString(IntPtr nativestring, int nativestringlen)
        {
          if (nativestring == IntPtr.Zero || nativestringlen == 0) return String.Empty;
    
    #if NETSTANDARD && !NETSTANDARD2_0
          if (nativestringlen < 0)
            return Marshal.PtrToStringUTF8(nativestring);
          else
            return Marshal.PtrToStringUTF8(nativestring, nativestringlen);
    #else
          if (nativestringlen < 0)
          {
            nativestringlen = 0;
    
            while (Marshal.ReadByte(nativestring, nativestringlen) != 0)
              nativestringlen++;
    
            if (nativestringlen == 0) return String.Empty;
          }
    
          byte[] byteArray = new byte[nativestringlen];
    
          Marshal.Copy(nativestring, byteArray, 0, nativestringlen);
    
          return _utf8.GetString(byteArray, 0, nativestringlen);
    #endif
            }
    ```
    
    Thank you!
    
  3. login: "anonymous"
  4. mimetype: "text/x-markdown"
  5. private_contact changed to: "4bc1e8ce7495dc3abb20ef2109ec243192989cb7"
  6. severity changed to: "Minor"
  7. status changed to: "Open"
  8. title changed to:
    Optimize SQLiteConvert.UTF8ToString for .NET Standard 2.1
    
  9. type changed to: "Performance"