Permalink
Browse files

Change iterators to use prefix ++ since it is more efficient.

This patch changes all the iterator code to use a prefix ++ instead
of postfix since it is more efficient (no need for a temporary). It
is likely that the compiler could optimize this away, but lets make
it efficient from the start.
  • Loading branch information...
1 parent 77feb50 commit 225ca1e205ae94db6fef12c109a7acbce97b2356 @caryr caryr committed with steveicarus Oct 23, 2010
Showing with 167 additions and 190 deletions.
  1. +3 −3 HName.h
  2. +1 −1 Makefile.in
  3. +1 −2 Module.cc
  4. +7 −7 design_dump.cc
  5. +1 −1 elab_expr.cc
  6. +22 −22 elab_scope.cc
  7. +13 −14 elab_sig.cc
  8. +19 −21 elaborate.cc
  9. +7 −7 emit.cc
  10. +1 −1 eval_attrib.cc
  11. +3 −3 functor.cc
  12. +1 −2 load_module.cc
  13. +14 −19 main.cc
  14. +8 −8 net_design.cc
  15. +4 −5 net_event.cc
  16. +1 −1 net_tran.cc
  17. +1 −1 netmisc.cc
  18. +1 −1 nodangle.cc
  19. +2 −2 parse.y
  20. +12 −20 pform.cc
  21. +2 −2 pform_disciplines.cc
  22. +25 −29 pform_dump.cc
  23. +1 −1 t-dll-api.cc
  24. +4 −4 t-dll.cc
  25. +1 −1 vvp/delay.cc
  26. +6 −6 vvp/island_tran.cc
  27. +1 −1 vvp/main.cc
  28. +1 −1 vvp/ufunc.cc
  29. +1 −1 vvp/vpi_vthr_vector.cc
  30. +1 −1 vvp/vthread.cc
  31. +2 −2 vvp/vvp_net.cc
View
@@ -1,7 +1,7 @@
#ifndef __HName_H
#define __HName_H
/*
- * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -94,10 +94,10 @@ inline ostream& operator<< (ostream&out, const list<hname_t>&ll)
{
list<hname_t>::const_iterator cur = ll.begin();
out << *cur;
- cur ++;
+ ++ cur;
while (cur != ll.end()) {
out << "." << *cur;
- cur ++;
+ ++ cur;
}
return out;
}
View
@@ -162,7 +162,7 @@ cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c
cppcheck-all:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) cppcheck && ) true
$(foreach dir,$(NOTUSED),$(MAKE) -C $(dir) cppcheck && ) true
- cppcheck
+ $(MAKE) cppcheck
Makefile: $(srcdir)/Makefile.in config.status
./config.status --file=$@
View
@@ -93,8 +93,7 @@ unsigned Module::find_port(const char*name) const
PGate* Module::get_gate(perm_string name)
{
for (list<PGate*>::iterator cur = gates_.begin()
- ; cur != gates_.end()
- ; cur ++ ) {
+ ; cur != gates_.end() ; ++ cur ) {
if ((*cur)->get_name() == name)
return *cur;
View
@@ -1112,7 +1112,7 @@ void NetScope::dump(ostream&o) const
{
map<perm_string,param_expr_t>::const_iterator pp;
for (pp = parameters.begin()
- ; pp != parameters.end() ; pp ++) {
+ ; pp != parameters.end() ; ++ pp ) {
o << " parameter ";
o << pp->second.type << " ";
@@ -1162,7 +1162,7 @@ void NetScope::dump(ostream&o) const
}
for (pp = localparams.begin()
- ; pp != localparams.end() ; pp ++) {
+ ; pp != localparams.end() ; ++ pp ) {
o << " localparam " << (*pp).first << " = " <<
*(*pp).second.expr << ";" << endl;
}
@@ -1172,7 +1172,7 @@ void NetScope::dump(ostream&o) const
{
list<pair<pform_name_t,NetExpr*> >::const_iterator pp;
for (pp = defparams.begin()
- ; pp != defparams.end() ; pp ++ ) {
+ ; pp != defparams.end() ; ++ pp ) {
o << " defparam " << (*pp).first << " = " <<
*(*pp).second << ";" << endl;
}
@@ -1181,7 +1181,7 @@ void NetScope::dump(ostream&o) const
{
list<pair<list<hname_t>,NetExpr*> >::const_iterator pp;
for (pp = defparams_later.begin()
- ; pp != defparams_later.end() ; pp ++ ) {
+ ; pp != defparams_later.end() ; ++ pp ) {
o << " defparam(later) " << pp->first << " = " <<
*(pp->second) << ";" << endl;
}
@@ -1203,7 +1203,7 @@ void NetScope::dump(ostream&o) const
// Dump specparams
typedef map<perm_string,spec_val_t>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin()
- ; cur != specparams.end() ; cur ++ ) {
+ ; cur != specparams.end() ; ++ cur ) {
o << " specparam " << (*cur).first
<< " = ";
spec_val_t value = (*cur).second;
@@ -1240,7 +1240,7 @@ void NetScope::dump(ostream&o) const
/* Dump any sub-scopes. */
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
- ; cur != children_.end() ; cur ++)
+ ; cur != children_.end() ; ++ cur )
cur->second->dump(o);
}
@@ -1518,7 +1518,7 @@ void Design::dump(ostream&o) const
o << "DESIGN TIME PRECISION: 10e" << get_precision() << endl;
o << "SCOPES:" << endl;
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
- scope != root_scopes_.end(); scope++)
+ scope != root_scopes_.end(); ++ scope )
(*scope)->dump(o);
o << "ELABORATED NODES:" << endl;
View
@@ -1984,7 +1984,7 @@ static void probe_index_expr_width(Design*des, NetScope*scope,
const name_component_t&name)
{
for (list<index_component_t>::const_iterator cur = name.index.begin()
- ; cur != name.index.end() ; cur ++) {
+ ; cur != name.index.end() ; ++ cur ) {
if (cur->msb)
probe_expr_width(des, scope, cur->msb);
View
@@ -53,7 +53,7 @@ static void collect_scope_parameters_(NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&parameters)
{
for (mparm_it_t cur = parameters.begin()
- ; cur != parameters.end() ; cur ++) {
+ ; cur != parameters.end() ; ++ cur ) {
NetEParam*tmp = new NetEParam;
tmp->set_line(*((*cur).second.expr));
@@ -68,7 +68,7 @@ static void collect_scope_localparams_(NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&localparams)
{
for (mparm_it_t cur = localparams.begin()
- ; cur != localparams.end() ; cur ++) {
+ ; cur != localparams.end() ; ++ cur ) {
NetEParam*tmp = new NetEParam;
tmp->set_line(*((*cur).second.expr));
@@ -172,7 +172,7 @@ static void elaborate_scope_parameters_(Design*des, NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&parameters)
{
for (mparm_it_t cur = parameters.begin()
- ; cur != parameters.end() ; cur ++) {
+ ; cur != parameters.end() ; ++ cur ) {
// A parameter can not have the same name as a genvar.
if (scope->find_genvar((*cur).first)) {
@@ -191,7 +191,7 @@ static void elaborate_scope_localparams_(Design*des, NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&localparams)
{
for (mparm_it_t cur = localparams.begin()
- ; cur != localparams.end() ; cur ++) {
+ ; cur != localparams.end() ; ++ cur ) {
// A localparam can not have the same name as a genvar.
if (scope->find_genvar((*cur).first)) {
@@ -210,7 +210,7 @@ static void replace_scope_parameters_(NetScope*scope, const LineInfo&loc,
const Module::replace_t&replacements)
{
for (Module::replace_t::const_iterator cur = replacements.begin()
- ; cur != replacements.end() ; cur ++) {
+ ; cur != replacements.end() ; ++ cur ) {
NetExpr*val = (*cur).second;
if (val == 0) {
@@ -240,7 +240,7 @@ static void elaborate_scope_events_(Design*des, NetScope*scope,
const map<perm_string,PEvent*>&events)
{
for (map<perm_string,PEvent*>::const_iterator et = events.begin()
- ; et != events.end() ; et ++ ) {
+ ; et != events.end() ; ++ et ) {
(*et).second->elaborate_scope(des, scope);
}
@@ -253,7 +253,7 @@ static void elaborate_scope_tasks(Design*des, NetScope*scope,
typedef map<perm_string,PTask*>::const_iterator tasks_it_t;
for (tasks_it_t cur = tasks.begin()
- ; cur != tasks.end() ; cur ++ ) {
+ ; cur != tasks.end() ; ++ cur ) {
hname_t use_name( (*cur).first );
// A task can not have the same name as another scope object.
@@ -308,7 +308,7 @@ static void elaborate_scope_funcs(Design*des, NetScope*scope,
typedef map<perm_string,PFunction*>::const_iterator funcs_it_t;
for (funcs_it_t cur = funcs.begin()
- ; cur != funcs.end() ; cur ++ ) {
+ ; cur != funcs.end() ; ++ cur ) {
hname_t use_name( (*cur).first );
// A function can not have the same name as another scope object.
@@ -376,7 +376,7 @@ class generate_schemes_work_item_t : public elaborator_work_item_t {
// elaboration.
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = mod_->generate_schemes.begin()
- ; cur != mod_->generate_schemes.end() ; cur ++ ) {
+ ; cur != mod_->generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope_);
}
}
@@ -399,7 +399,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
// Add the genvars to the scope.
typedef map<perm_string,LineInfo*>::const_iterator genvar_it_t;
- for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); cur++ ) {
+ for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); ++ cur ) {
scope->add_genvar((*cur).first, (*cur).second);
}
@@ -446,7 +446,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
typedef list<Module::named_expr_t>::const_iterator defparms_iter_t;
for (defparms_iter_t cur = defparms.begin()
- ; cur != defparms.end() ; cur ++) {
+ ; cur != defparms.end() ; ++ cur ) {
PExpr*ex = cur->second;
assert(ex);
@@ -496,7 +496,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
typedef list<PGate*>::const_iterator gates_it_t;
for (gates_it_t cur = gates_.begin()
- ; cur != gates_.end() ; cur ++ ) {
+ ; cur != gates_.end() ; ++ cur ) {
(*cur) -> elaborate_scope(des, scope);
}
@@ -509,7 +509,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
- ; cur != behaviors.end() ; cur ++ ) {
+ ; cur != behaviors.end() ; ++ cur ) {
(*cur) -> statement() -> elaborate_scope(des, scope);
}
@@ -849,7 +849,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
// Detect that the item is a default.
if (item->item_test.size() == 0) {
default_item = item;
- cur ++;
+ ++ cur;
continue;
}
@@ -881,7 +881,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
if (match_flag)
break;
- cur ++;
+ ++ cur;
}
delete case_value_co;
@@ -1017,7 +1017,7 @@ void PGenerate::elaborate_subscope_direct_(Design*des, NetScope*scope)
{
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope);
}
}
@@ -1026,7 +1026,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
{
// Add the genvars to this scope.
typedef map<perm_string,LineInfo*>::const_iterator genvar_it_t;
- for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); cur++ ) {
+ for (genvar_it_t cur = genvars.begin(); cur != genvars.end(); ++ cur ) {
scope->add_genvar((*cur).first, (*cur).second);
}
@@ -1036,7 +1036,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
- ; cur != generate_schemes.end() ; cur ++ ) {
+ ; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope);
}
@@ -1057,13 +1057,13 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
// their own scopes.
typedef list<PGate*>::const_iterator pgate_list_it_t;
for (pgate_list_it_t cur = gates.begin()
- ; cur != gates.end() ; cur ++) {
+ ; cur != gates.end() ; ++ cur ) {
(*cur) ->elaborate_scope(des, scope);
}
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
- ; cur != behaviors.end() ; cur ++ ) {
+ ; cur != behaviors.end() ; ++ cur ) {
(*cur) -> statement() -> elaborate_scope(des, scope);
}
@@ -1331,7 +1331,7 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s
replace[*cur] = (*overrides_)[jdx];
jdx += 1;
- cur ++;
+ ++ cur;
}
}
@@ -1352,7 +1352,7 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s
// parameter value with the new expression.
for (mparm_local_it_t cur = replace.begin()
- ; cur != replace.end() ; cur ++ ) {
+ ; cur != replace.end() ; ++ cur ) {
PExpr*tmp = (*cur).second;
// No expression means that the parameter is not
Oops, something went wrong.

0 comments on commit 225ca1e

Please sign in to comment.