mpn_neg

tg at gmplib.org tg at gmplib.org
Wed Apr 29 11:51:08 UTC 2015


nisse at lysator.liu.se (Niels Möller) writes:

  tg at gmplib.org writes:
  
  >   Not sure why we're doing this as an inline function in gmp.h.
  >   
  > Me neither.  Perhaps as it is tiny?
  
  I think inlines in gmp.h makes sense for functions which are tiny and
  O(1) in the common case, like mpn_add_1 and mpn_cmp. Or small O(1)
  wrappers around O(n) functions, like mpn_add. Any other criteria?
  
I agree (without having looked deeply into how these things work today).

Some of the decisions were reasonable at the time they were made;
mpn_neg presumably saved some O(1) time before there were wide memops.
(Then one may ask how many programs depend measurably on any such
mpn_neg savings.)

  The current mpn_neg isn't of that type, but maybe it could be if it
  defers the main work to mpn_com.
  
I think we could as well leave it, but make changes as per Marco's or
your suggestion.  I think your suggestion will actually inline less
code, so I'd vote for that.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list