-
-
Notifications
You must be signed in to change notification settings - Fork 160
Closed
Description
- profile the examples apps to determine hot paths
- setup a benchmarkdotnet project
- write benchmarks for known hot paths
- optimize based on benchmarks
Known Issues:
- improper use of
List/IEnumerable:- allocating a new list just to
forEachit:value.Split(',').ToList().ForEach(p =>
- allocating a new list just to
- using string literals instead of
const:var operation = value.Split(':'); value = string.Join(":", operation.Skip(1)); return string.IsNullOrEmpty(contentTypeString) || contentTypeString == "application/vnd.api+json";
- Can we improve performance by providing generic overloads with constraints over type checking:
- instead of:
JsonApiDotNetCore/src/JsonApiDotNetCore/Models/Identifiable.cs
Lines 26 to 30 in 0664c3d
if(type == typeof(Guid)) { var guid = Guid.Parse(stringValue); return guid == Guid.Empty ? string.Empty : stringValue; } - can we do something like:
- instead of:
public class Identifiable<T> : IIdentifiable<T> where T : Guid {
// ...
}- Use BaseController instead of Controller
- Use
.AsNoTracking()on read-only queries - Use
.Attach(/*..*/)instead of first callingGetAsync(/*..*/)in PATCH requests
JsonApiDotNetCore/src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs
Lines 120 to 133 in ef147e4
public virtual async Task<TEntity> UpdateAsync(TId id, TEntity entity) { var oldEntity = await GetAsync(id); if (oldEntity == null) return null; foreach (var attr in _jsonApiContext.AttributesToUpdate) attr.Key.SetValue(oldEntity, attr.Value); foreach (var relationship in _jsonApiContext.RelationshipsToUpdate) relationship.Key.SetValue(oldEntity, relationship.Value); await _context.SaveChangesAsync();