What is the difference between "mod misc;" and "extern mod misc;", other
than the obvious linking with libmisc-...so? (Yeah, I'm a great namer.)

I was moving a function from a program into a separate module, importing
the module with "mod misc;", and my program went from taking ~6 seconds
to ~32 seconds. After some experimentation, I discovered that using
"extern mod misc;" and separately compiling misc.rs, the run time went
back down to ~6 seconds.

The weird part is that the function I moved contains the working loop of
the program; it is called once by main.

I compiled the original program with:

  rust build -O proggie.rs

and the program with the separate, "mod misc;" imported module with:

  rust build -O proggie.rs

and the third version with the separate crate misc with:

  rust build -O misc.rs
  rust build -L. -O proggie.rs

I'm using rust 0.6.

---

It occurs to me on second thought (since I can't get to the 'net to send
this at the moment) that I've introduced another level of modules here,
since the code was already calling functions from a third module.
Originally, the function I moved, search, called a function from another
module, combinations::each_combination, also imported with "mod".
Following the move, main calls misc::search, which calls
combinations::each_combination, and combinations was imported into misc
via "mod" in addition to misc being imported into the main program via
"mod".


-- 
Tommy M. McGuire
[email protected]
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to