正如Knuth所说,
我们应该忘记小的效率,大约97%的时间说:过早的优化是所有邪恶的根源.
这是Stack Overflow常常出现的问题,例如"哪个是最有效的循环机制","SQL优化技术?"等问题.(等等).这些优化提示问题的标准答案是分析您的代码并首先查看它是否是一个问题,如果不是,那么您的新技术就不再需要了.
我的问题是,如果某种技术不同但不是特别模糊或混淆,那真的可以被认为是过早的优化吗?
这是Randall Hyde的一篇名为"过早优化的谬误"的相关文章.
目前我有一个谷歌地图,将在我的数据库中显示地图上的一些标记...我想在用户点击标记时添加一个信息窗口.
我让它工作,但问题是它只显示在最后加载的标记上,为什么会这样?
这是生成标记和infowindow的代码.
<script type="text/javascript">
function initialize() {
var myOptions = {
zoom: 3,
center: new google.maps.LatLng(41.850033, -87.6500523),
disableDefaultUI: true,
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, offices);
}
/**
* Data for the markers consisting of a name, a LatLng and a zIndex for
* the order in which these markers should display on top of each
* other.
*/
var offices = [<cfoutput>#officeList#</cfoutput>];
function setMarkers(map, locations) {
// Add markers to the map …Run Code Online (Sandbox Code Playgroud)