optimize nested for loops within nested if statements

I am trying to optimize this code. The only optimization I can think of is to a return or break statement after applyOfferChanges(…) inside the second if condition. Any ideas? void applyFavoriteChangesToMerchantStore(){ List<Merchant> favoriteMerchantsList = FavoriteMerchantStore.getInstance().getFavoriteMerchantsList(); if(favoriteMerchantsList != null && !favoriteMerchantsList.isEmpty()) { List<Merchant> storeMerchantList = MerchantStore.getInstance().getMerchantList(); for (Merchant storeMerchant : storeMerchantList) { for (Merchant favoriteMerchant:…

Details

How to configure dotnetcore 3 site to return 401 with custom authorization filter rather than redirecting to AccessDenied page

I’ve got a site using the new dotnetcore3 angular template. I’ve created a custom authorization filter that’s currently extremely simple public class ClaimRequirementFilter : IAuthorizationFilter { readonly string _claim; public ClaimRequirementFilter(string claim) { _claim = claim; } public void OnAuthorization(AuthorizationFilterContext context) { if (_claim != “test”) { context.Result = new ForbidResult(); } } } public…

Details

Solve equation with python

I hope someone can help me, I try to solve an equation, in principle the idea is to insolate the variable t from the following equation: import math import sympy from sympy.solvers import solve from sympy import Symbol a=Symbol (‘a’) t=Symbol (‘t’) S=Symbol(‘S’) g=Symbol (‘g’) h=Symbol(‘h’) f=solve(sympy.exp(t*S/2)*(1+(3/2)*t*g*(h-S/2))**(2/(3*g)),t) print (f) and I get the following: [0.333333333333333*(4.0…

Details