System.Data.SQLite

Check-in [ca18c8f4dd]
Login

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

Overview
Comment:Avoid unnecessary lock contention and managed heap allocations in the data type mapping subsystem.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ca18c8f4ddc5d60bc2a77e460bad256455f83a8a
User & Date: mistachkin 2017-11-07 01:00:47.063
Context
2017-11-07
01:42
Fix incorrect memory allocation counts in the SQLiteSession class for SQLite memory obtained without using the SQLiteMemory class. Only debug builds with TRACK_MEMORY_BYTES defined were impacted. check-in: 395909320d user: mistachkin tags: trunk
01:00
Avoid unnecessary lock contention and managed heap allocations in the data type mapping subsystem. check-in: ca18c8f4dd user: mistachkin tags: trunk
2017-11-02
02:37
Final updates for release 1.0.106.0. check-in: 62313f295f user: mistachkin tags: trunk, release, release-1.0.106.0
Changes
Unified Diff Ignore Whitespace Patch
Changes to System.Data.SQLite/SQLiteConvert.cs.
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568

1569

1570

1571
1572
1573
1574
1575
1576
1577
#if !NET_COMPACT_20 && TRACE_WARNING
            DefaultTypeNameWarning(dbType, flags, defaultTypeName);
#endif

            return defaultTypeName;
        }

        lock (_syncRoot)
        {
            if (_typeNames == null)
                _typeNames = GetSQLiteDbTypeMap();

            SQLiteDbTypeMapping value;


            if (_typeNames.TryGetValue(dbType, out value))

                return value.typeName;

        }

        if (defaultTypeName != null)
            return defaultTypeName;

        defaultTypeName = GetDefaultTypeName(connection);








<

<
<
<


>
|
>

>







1555
1556
1557
1558
1559
1560
1561

1562



1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
#if !NET_COMPACT_20 && TRACE_WARNING
            DefaultTypeNameWarning(dbType, flags, defaultTypeName);
#endif

            return defaultTypeName;
        }


        {



            SQLiteDbTypeMapping value;

            if ((_typeNames != null) &&
                _typeNames.TryGetValue(dbType, out value))
            {
                return value.typeName;
            }
        }

        if (defaultTypeName != null)
            return defaultTypeName;

        defaultTypeName = GetDefaultTypeName(connection);

2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
#if !NET_COMPACT_20 && TRACE_WARNING
            DefaultDbTypeWarning(typeName, flags, defaultDbType);
#endif

            return (DbType)defaultDbType;
        }

        lock (_syncRoot)
        {
            if (_typeNames == null)
                _typeNames = GetSQLiteDbTypeMap();

            if (typeName != null)
            {
                SQLiteDbTypeMapping value;

                if (_typeNames.TryGetValue(typeName, out value))
                {
                    return value.dataType;
                }







<

<
<
<
|







2104
2105
2106
2107
2108
2109
2110

2111



2112
2113
2114
2115
2116
2117
2118
2119
#if !NET_COMPACT_20 && TRACE_WARNING
            DefaultDbTypeWarning(typeName, flags, defaultDbType);
#endif

            return (DbType)defaultDbType;
        }


        {



            if ((_typeNames != null) && (typeName != null))
            {
                SQLiteDbTypeMapping value;

                if (_typeNames.TryGetValue(typeName, out value))
                {
                    return value.dataType;
                }
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
        DefaultDbTypeWarning(typeName, flags, defaultDbType);
#endif

        return (DbType)defaultDbType;
    }
    #endregion

    private static object _syncRoot = new object();
    private static SQLiteDbTypeMap _typeNames = null;
  }

  /// <summary>
  /// SQLite has very limited types, and is inherently text-based.  The first 5 types below represent the sum of all types SQLite
  /// understands.  The DateTime extension to the spec is for internal use only.
  /// </summary>
  public enum TypeAffinity







<
|







2139
2140
2141
2142
2143
2144
2145

2146
2147
2148
2149
2150
2151
2152
2153
        DefaultDbTypeWarning(typeName, flags, defaultDbType);
#endif

        return (DbType)defaultDbType;
    }
    #endregion


    private static readonly SQLiteDbTypeMap _typeNames = GetSQLiteDbTypeMap();
  }

  /// <summary>
  /// SQLite has very limited types, and is inherently text-based.  The first 5 types below represent the sum of all types SQLite
  /// understands.  The DateTime extension to the spec is for internal use only.
  /// </summary>
  public enum TypeAffinity
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
      //
      // NOTE: The only thing that we must guarantee here, according
      //       to the MSDN documentation for IEqualityComparer, is
      //       that for two given strings, if Equals return true then
      //       the two strings must hash to the same value.
      //
      if (value != null)
#if !PLATFORM_COMPACTFRAMEWORK
        return value.ToLowerInvariant().GetHashCode();
#else
        return value.ToLower().GetHashCode();
#endif
      else
        throw new ArgumentNullException("value");
    }
    #endregion

    ///////////////////////////////////////////////////////////////////////////








<
<
<
|
<







2931
2932
2933
2934
2935
2936
2937



2938

2939
2940
2941
2942
2943
2944
2945
      //
      // NOTE: The only thing that we must guarantee here, according
      //       to the MSDN documentation for IEqualityComparer, is
      //       that for two given strings, if Equals return true then
      //       the two strings must hash to the same value.
      //
      if (value != null)



        return StringComparer.OrdinalIgnoreCase.GetHashCode(value);

      else
        throw new ArgumentNullException("value");
    }
    #endregion

    ///////////////////////////////////////////////////////////////////////////