System.Data.SQLite
Check-in [a97d149d1e]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor optimization to GetBytes() to avoid calling sqlite3_column_blob() on null destination buffers. Fix for [8c1650482e].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a97d149d1e56f612d5327c4adcc5db8d22258e81
User & Date: shaneh 2011-05-24 01:39:23
References
2013-01-01
19:32 Closed ticket [8c1650482e]: SQLite3.GetBytes optimization plus 3 other changes artifact: 8bbf52212d user: mistachkin
2011-05-24
01:40 Fixed ticket [8c1650482e]. artifact: beca12706f user: shane
Context
2011-06-02
15:17
Update to SQlite 3.7.6.3 [ed1da510a2]. check-in: 9067143122 user: shaneh tags: trunk
2011-05-24
01:39
Minor optimization to GetBytes() to avoid calling sqlite3_column_blob() on null destination buffers. Fix for [8c1650482e]. check-in: a97d149d1e user: shaneh tags: trunk
01:20
Update various assembly information settings. check-in: 606af726e9 user: shaneh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLite3.cs.

607
608
609
610
611
612
613
614
615
616
617
618
619
620
621


622



623

624
625
626
627
628
629
630
    internal override long GetBytes(SQLiteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart, int nLength)
    {
      IntPtr ptr;
      int nlen;
      int nCopied = nLength;

      nlen = UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index);
      ptr = UnsafeNativeMethods.sqlite3_column_blob(stmt._sqlite_stmt, index);

      if (bDest == null) return nlen;

      if (nCopied + nStart > bDest.Length) nCopied = bDest.Length - nStart;
      if (nCopied + nDataOffset > nlen) nCopied = nlen - nDataOffset;

      if (nCopied > 0)


        Marshal.Copy((IntPtr)(ptr.ToInt64() + nDataOffset), bDest, nStart, nCopied);



      else nCopied = 0;


      return nCopied;
    }

    internal override long GetChars(SQLiteStatement stmt, int index, int nDataOffset, char[] bDest, int nStart, int nLength)
    {
      int nlen;







|
<






>
>

>
>
>
|
>







607
608
609
610
611
612
613
614

615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
    internal override long GetBytes(SQLiteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart, int nLength)
    {
      IntPtr ptr;
      int nlen;
      int nCopied = nLength;

      nlen = UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index);
      // If no destination buffer, return the size needed.

      if (bDest == null) return nlen;

      if (nCopied + nStart > bDest.Length) nCopied = bDest.Length - nStart;
      if (nCopied + nDataOffset > nlen) nCopied = nlen - nDataOffset;

      if (nCopied > 0)
      {
        ptr = UnsafeNativeMethods.sqlite3_column_blob(stmt._sqlite_stmt, index);
        Marshal.Copy((IntPtr)(ptr.ToInt64() + nDataOffset), bDest, nStart, nCopied);
      }
      else
      {
        nCopied = 0;
      }

      return nCopied;
    }

    internal override long GetChars(SQLiteStatement stmt, int index, int nDataOffset, char[] bDest, int nStart, int nLength)
    {
      int nlen;