<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/libcore/num, branch master</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=master</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=master'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2020-07-28T00:51:13+00:00</updated>
<entry>
<title>mv std libs to library/</title>
<updated>2020-07-28T00:51:13+00:00</updated>
<author>
<name>mark</name>
<email>markm@cs.wisc.edu</email>
</author>
<published>2020-06-12T02:31:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2c31b45ae878b821975c4ebd94cc1e49f6073fd0'/>
<id>urn:sha1:2c31b45ae878b821975c4ebd94cc1e49f6073fd0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #73858 - tspiteri:const-methods, r=oli-obk</title>
<updated>2020-07-27T16:20:15+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-27T16:20:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7864c3f5fa709b854aeee4c45fd00f834ed75449'/>
<id>urn:sha1:7864c3f5fa709b854aeee4c45fd00f834ed75449</id>
<content type='text'>
Make more primitive integer methods const

Now that #72437 has been merged and `const_if_match` is stable, these methods can be stabilized const. The methods are grouped in commits according to feature names:

* `const_nonzero_int_methods`
    - `NonZero*::new`
* some `const_checked_int_methods`
    - `{i*,u*}::checked_add`
    - `{i*,u*}::checked_sub`
    - `{i*,u*}::checked_mul`
    - `{i*,u*}::checked_neg`
    - `{i*,u*}::checked_shl`
    - `{i*,u*}::checked_shr`
    - `i*::checked_abs`
* `const_saturating_int_methods`
    - `{i*,u*}::saturating_add`
    - `{i*,u*}::saturating_sub`
    - `{i*,u*}::saturating_mul`
    - `i*::saturating_neg`
    - `i*::saturating_abs`
* `const_int_sign`
    - `i*::signum`
* `const_ascii_ctype_on_intrinsics`
    - `{char,u8}::is_ascii_alphabetic`
    - `{char,u8}::is_ascii_uppercase`
    - `{char,u8}::is_ascii_lowercase`
    - `{char,u8}::is_ascii_alphanumeric`
    - `{char,u8}::is_ascii_digit`
    - `{char,u8}::is_ascii_hexdigit`
    - `{char,u8}::is_ascii_punctuation`
    - `{char,u8}::is_ascii_graphic`
    - `{char,u8}::is_ascii_whitespace`
    - `{char,u8}::is_ascii_control`
</content>
</entry>
<entry>
<title>Rollup merge of #74367 - Neutron3529:patch-1, r=nagisa</title>
<updated>2020-07-24T17:01:30+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-24T17:01:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3226d723381a24118f6aaa73b096c8ef4510f189'/>
<id>urn:sha1:3226d723381a24118f6aaa73b096c8ef4510f189</id>
<content type='text'>
Rearrange the pipeline of `pow` to gain efficiency

The check of the `exp` parameter seems useless if we execute the while-loop more than once.
The original implementation of `pow` function using one more comparison if the `exp==0` and may break the pipeline of the cpu, which may generate a slower code.
The performance gap between the old and the new implementation may be small, but IMO, at least the newer one looks more beautiful.

---

bench prog:
```
#![feature(test)]
extern crate test;
#[macro_export]macro_rules! timing{
($a:expr)=&gt;{let time=std::time::Instant::now();{$a;}print!("{:?} ",time.elapsed())};
($a:expr,$b:literal)=&gt;{let time=std::time::Instant::now();let mut a=0;for _ in 0..$b{a^=$a;}print!("{:?} {} ",time.elapsed(),a)}
}
#[inline]
pub fn pow_rust(x:i64, mut exp: u32) -&gt; i64 {
    let mut base = x;
    let mut acc = 1;
    while exp &gt; 1 {
        if (exp &amp; 1) == 1 {
            acc = acc * base;
        }
        exp /= 2;
        base = base * base;
    }
    if exp == 1 {
        acc = acc * base;
    }
    acc
}
#[inline]
pub fn pow_new(x:i64, mut exp: u32) -&gt; i64 {
    if exp==0{
        1
    }else{
        let mut base = x;
        let mut acc = 1;
        while exp &gt; 1 {
            if (exp &amp; 1) == 1 {
                acc = acc * base;
            }
            exp &gt;&gt;= 1;
            base = base * base;
        }
        acc * base
    }
}

fn main(){
let a=2i64;
let b=1_u32;
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
}
```
bench in my laptop:
```
neutron@Neutron:/me/rust$ rc commit.rs
rustc commit.rs  &amp;&amp; ./commit

3.978419716s 0 4.079765171s 0 3.964630622s 0
3.997127013s 0 4.260304804s 0 3.997638211s 0
3.963195544s 0 4.11657718s 0 4.176054164s 0
3.830128579s 0 3.980396122s 0 3.937258567s 0
3.986055948s 0 4.127804162s 0 4.018943411s 0
4.185568857s 0 4.217512517s 0 3.98313603s 0
3.863018225s 0 4.030447988s 0 3.694878237s 0
4.206987927s 0 4.137608047s 0 4.115564664s 0
neutron@Neutron:/me/rust$ rc commit.rs -O
rustc commit.rs -O &amp;&amp; ./commit

162.111993ms 0 165.107125ms 0 166.26924ms 0
175.20479ms 0 205.062565ms 0 176.278791ms 0
174.408975ms 0 166.526899ms 0 201.857604ms 0
146.190062ms 0 168.592821ms 0 154.61411ms 0
199.678912ms 0 168.411598ms 0 162.129996ms 0
147.420765ms 0 209.759326ms 0 154.807907ms 0
165.507134ms 0 188.476239ms 0 157.351524ms 0
121.320123ms 0 126.401229ms 0 114.86428ms 0
```
</content>
</entry>
<entry>
<title>Rollup merge of #74141 - euclio:typos, r=steveklabnik</title>
<updated>2020-07-23T07:42:01+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-23T07:42:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9be109910713660e666f83ebdc6a6e717391e647'/>
<id>urn:sha1:9be109910713660e666f83ebdc6a6e717391e647</id>
<content type='text'>
libstd/libcore: fix various typos
</content>
</entry>
<entry>
<title>Rearrange the pipeline of `pow` to gain efficiency</title>
<updated>2020-07-23T06:55:15+00:00</updated>
<author>
<name>Neutron3529</name>
<email>qweytr_1@163.com</email>
</author>
<published>2020-07-15T14:39:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ef74e5084386f82b4285fd7d3630cf1088eebb3f'/>
<id>urn:sha1:ef74e5084386f82b4285fd7d3630cf1088eebb3f</id>
<content type='text'>
The check of the `exp` parameter seems useless if we execute the while-loop more than once.
The original implementation of `pow` function using one more comparison if the `exp==0` and may break the pipeline of the cpu, which may generate a slower code.
The performance gap between the old and the new implementation may be small, but IMO, at least the newer one looks more beautiful.

---

bench prog:
```
extern crate test;
($a:expr)=&gt;{let time=std::time::Instant::now();{$a;}print!("{:?} ",time.elapsed())};
($a:expr,$b:literal)=&gt;{let time=std::time::Instant::now();let mut a=0;for _ in 0..$b{a^=$a;}print!("{:?} {} ",time.elapsed(),a)}
}
pub fn pow_rust(x:i64, mut exp: u32) -&gt; i64 {
    let mut base = x;
    let mut acc = 1;
    while exp &gt; 1 {
        if (exp &amp; 1) == 1 {
            acc = acc * base;
        }
        exp /= 2;
        base = base * base;
    }
    if exp == 1 {
        acc = acc * base;
    }
    acc
}
pub fn pow_new(x:i64, mut exp: u32) -&gt; i64 {
    if exp==0{
        1
    }else{
        let mut base = x;
        let mut acc = 1;
        while exp &gt; 1 {
            if (exp &amp; 1) == 1 {
                acc = acc * base;
            }
            exp &gt;&gt;= 1;
            base = base * base;
        }
        acc * base
    }
}

fn main(){
let a=2i64;
let b=1_u32;
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
}
```
bench in my laptop:
```
neutron@Neutron:/me/rust$ rc commit.rs
rustc commit.rs  &amp;&amp; ./commit

3.978419716s 0 4.079765171s 0 3.964630622s 0
3.997127013s 0 4.260304804s 0 3.997638211s 0
3.963195544s 0 4.11657718s 0 4.176054164s 0
3.830128579s 0 3.980396122s 0 3.937258567s 0
3.986055948s 0 4.127804162s 0 4.018943411s 0
4.185568857s 0 4.217512517s 0 3.98313603s 0
3.863018225s 0 4.030447988s 0 3.694878237s 0
4.206987927s 0 4.137608047s 0 4.115564664s 0
neutron@Neutron:/me/rust$ rc commit.rs -O
rustc commit.rs -O &amp;&amp; ./commit

162.111993ms 0 165.107125ms 0 166.26924ms 0
175.20479ms 0 205.062565ms 0 176.278791ms 0
174.408975ms 0 166.526899ms 0 201.857604ms 0
146.190062ms 0 168.592821ms 0 154.61411ms 0
199.678912ms 0 168.411598ms 0 162.129996ms 0
147.420765ms 0 209.759326ms 0 154.807907ms 0
165.507134ms 0 188.476239ms 0 157.351524ms 0
121.320123ms 0 126.401229ms 0 114.86428ms 0
```

delete an unnecessary semicolon...

Sorry for the typo.

delete trailing whitespace

Sorry, too..

Sorry for the missing...

I checked all the implementations, and finally found that there is one function that does not check whether `exp == 0`

add extra tests

add extra tests.

finished adding the extra tests to prevent further typo

add pow(2) to negative exp

add whitespace.

add whitespace

add whitespace

delete extra line
</content>
</entry>
<entry>
<title>mark methods as constant since 1.47.0 instead of 1.46.0</title>
<updated>2020-07-22T08:07:20+00:00</updated>
<author>
<name>Trevor Spiteri</name>
<email>tspiteri@ieee.org</email>
</author>
<published>2020-07-22T07:16:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d6cf128b45b4e7b370357b9497d68426719b0d5a'/>
<id>urn:sha1:d6cf128b45b4e7b370357b9497d68426719b0d5a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Stabilize TAU constant.</title>
<updated>2020-07-20T12:01:25+00:00</updated>
<author>
<name>Mara Bos</name>
<email>m-ou.se@m-ou.se</email>
</author>
<published>2020-07-10T10:08:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5d4147a965fdd0c9766cd8ed934b33a836fcd6f6'/>
<id>urn:sha1:5d4147a965fdd0c9766cd8ed934b33a836fcd6f6</id>
<content type='text'>
Closes #66770.
</content>
</entry>
<entry>
<title>apply bootstrap cfgs</title>
<updated>2020-07-16T23:36:49+00:00</updated>
<author>
<name>Mark Rousskov</name>
<email>mark.simulacrum@gmail.com</email>
</author>
<published>2020-07-16T13:12:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=647d9b525fcda07695809b851b4d6bce05b34e61'/>
<id>urn:sha1:647d9b525fcda07695809b851b4d6bce05b34e61</id>
<content type='text'>
</content>
</entry>
<entry>
<title>libstd/libcore: fix various typos</title>
<updated>2020-07-09T14:57:11+00:00</updated>
<author>
<name>Andy Russell</name>
<email>arussell123@gmail.com</email>
</author>
<published>2020-07-08T00:48:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=133e91da627a42218721caf2083c3f309e1b0dcc'/>
<id>urn:sha1:133e91da627a42218721caf2083c3f309e1b0dcc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #73938 - nbdd0121:checked_opt, r=nagisa</title>
<updated>2020-07-02T07:16:41+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-02T07:16:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=4f536f2c36622328e7eb1d859cb74ba0a7d34ac8'/>
<id>urn:sha1:4f536f2c36622328e7eb1d859cb74ba0a7d34ac8</id>
<content type='text'>
Optimise fast path of checked_ops with `unlikely`

This PR marks paths returning `None` in checked_ops as unlikely to improvde codegen.

Fixes #73731
</content>
</entry>
</feed>
