gyp: fix O(n^2) in dependency calculations.
gyp: fix O(n^2) in dependency calculations.

With 1000 targets an O(n^2) in the dependency management starts to be
noticed. This patch takes a 0.2s function to 0.02s. The function is not
parallelized so this is a true 1% speedup.

Also commented on another *potential* performance problem with very
specific dependency graphs.

BUG=362075
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/234813003/
Patch from Daniel Bratell <bratell@opera.com>!


git-svn-id: e7e1075985beda50ea81ac4472467b4f6e91fc78@1898 78cadc50-ecff-11dd-a971-7dbc132099af

cchamberlain/gyp,clar/gyp,LazyCodingCat/gyp,azunite/gyp_20150930,android-ia/platform_external_chromium_org_tools_gyp,carlTLR/gyp,tarc/gyp,bpsinc-native/src_tools_gyp,openpeer/webrtc-gyp,clar/gyp,trafi/gyp,duanhjlt/gyp,saghul/gyn,AOSPU/external_chromium_org_tools_gyp,springmeyer/gyp,enkripsi/gyp,turbulenz/gyp,chromium/gyp,AOSPU/external_chromium_org_tools_gyp,springmeyer/gyp,AWhetter/gyp,sdklite/gyp,amoikevin/gyp,erikge/watch_gyp,ttyangf/pdfium_gyp,dougbeal/gyp,Jack-Q/GYP-copy,cysp/gyp,sport-monkey/GYP,sport-monkey/GYP,mgamer/gyp,trafi/gyp,duanhjlt/gyp,bnoordhuis/gyp,Jack-Q/GYP-copy,ttyangf/gyp,enkripsi/gyp,openpeer/webrtc-gyp,bulldy80/gyp_unofficial,Chilledheart/gyp,sanyaade-teachings/gyp,chromium/gyp,adblockplus/gyp,Omegaphora/external_chromium_org_tools_gyp,Danath/gyp,bulldy80/gyp_unofficial,ryfx/gyp,turbulenz/gyp,carlTLR/gyp,bnq4ever/gypgoogle,enkripsi/gyp,xin3liang/platform_external_chromium_org_tools_gyp,azunite/gyp_20150930,Phuehvk/gyp,sport-monkey/GYP,Chilledheart/gyp,sdklite/gyp,trafi/gyp,mgamer/gyp,erikge/watch_gyp,bulldy80/gyp_unofficial,adblockplus/gyp,saghul/gyn,AWhetter/gyp,erikge/watch_gyp,bnoordhuis/gyp,Danath/gyp,carlTLR/gyp,mapbox/gyp,sport-monkey/GYP,msc-/gyp,AOSPU/external_chromium_org_tools_gyp,openpeer/webrtc-gyp,Phuehvk/gyp,clar/gyp,azunite/gyp,AOSPU/external_chromium_org_tools_gyp,turbulenz/gyp,dougbeal/gyp,LazyCodingCat/gyp,cysp/gyp,ryfx/gyp,dougbeal/gyp,geekboxzone/lollipop_external_chromium_org_tools_gyp,azunite/gyp,geekboxzone/lollipop_external_chromium_org_tools_gyp,android-ia/platform_external_chromium_org_tools_gyp,azunite/gyp,sanyaade-teachings/gyp,amoikevin/gyp,bpsinc-native/src_tools_gyp,carlTLR/gyp,LazyCodingCat/gyp,bnoordhuis/gyp,geekboxzone/lollipop_external_chromium_org_tools_gyp,cchamberlain/gyp,bnq4ever/gypgoogle,bulldy80/gyp_unofficial,cchamberlain/gyp,adblockplus/gyp,cchamberlain/gyp,Omegaphora/external_chromium_org_tools_gyp,springmeyer/gyp,chromium/gyp,trafi/gyp,bnoordhuis/gyp,dougbeal/gyp,tarc/gyp,azunite/gyp,Omegaphora/external_chromium_org_tools_gyp,sdklite/gyp,mgamer/gyp,amoikevin/gyp,adblockplus/gyp,msc-/gyp,ttyangf/gyp,duanhjlt/gyp,cysp/gyp,LazyCodingCat/gyp,tarc/gyp,sdklite/gyp,springmeyer/gyp,trafi/gyp,LazyCodingCat/gyp,erikge/watch_gyp,sanyaade-teachings/gyp,amoikevin/gyp,bulldy80/gyp_unofficial,msc-/gyp,saghul/gyn,Phuehvk/gyp,mapbox/gyp,xin3liang/platform_external_chromium_org_tools_gyp,bnq4ever/gypgoogle,azunite/gyp_20150930,yjhjstz/gyp,clar/gyp,Jack-Q/GYP-copy,Danath/gyp,ttyangf/pdfium_gyp,cysp/gyp,bnoordhuis/gyp,mgamer/gyp,Omegaphora/external_chromium_org_tools_gyp,ryfx/gyp,ttyangf/gyp,ryfx/gyp,tarc/gyp,pandaxcl/gyp,springmeyer/gyp,erikge/watch_gyp,enkripsi/gyp,chromium/gyp,clar/gyp,Jack-Q/GYP-copy,amoikevin/gyp,Phuehvk/gyp,ttyangf/gyp,sanyaade-teachings/gyp,Chilledheart/gyp,chromium/gyp,azunite/gyp_20150930,cchamberlain/gyp,openpeer/webrtc-gyp,Danath/gyp,yjhjstz/gyp,sanyaade-teachings/gyp,msc-/gyp,AWhetter/gyp,yjhjstz/gyp,geekboxzone/lollipop_external_chromium_org_tools_gyp,turbulenz/gyp,adblockplus/gyp,Phuehvk/gyp,AWhetter/gyp,mgamer/gyp,bnq4ever/gypgoogle,ttyangf/pdfium_gyp,xin3liang/platform_external_chromium_org_tools_gyp,AWhetter/gyp,sport-monkey/GYP,pandaxcl/gyp,openpeer/webrtc-gyp,pandaxcl/gyp,Jack-Q/GYP-copy,sdklite/gyp,azunite/gyp,Danath/gyp,saghul/gyn,android-ia/platform_external_chromium_org_tools_gyp,tarc/gyp,enkripsi/gyp,android-ia/platform_external_chromium_org_tools_gyp,cysp/gyp,ryfx/gyp,mapbox/gyp,bnq4ever/gypgoogle,duanhjlt/gyp,Chilledheart/gyp,duanhjlt/gyp,pandaxcl/gyp,bpsinc-native/src_tools_gyp,ttyangf/gyp,xin3liang/platform_external_chromium_org_tools_gyp,ttyangf/pdfium_gyp,carlTLR/gyp,turbulenz/gyp,msc-/gyp,yjhjstz/gyp,azunite/gyp_20150930,bpsinc-native/src_tools_gyp,dougbeal/gyp,pandaxcl/gyp,ttyangf/pdfium_gyp,mapbox/gyp,yjhjstz/gyp,Chilledheart/gyp,saghul/gyn,mapbox/gyp