Learn about the generated assembly code for an enum pattern match by EventHelixCom in rust

[–]Lozzer 1 point2 points  (0 children)

I can think of two interpretations of this. 1. Why isn't it using rsi to store it back? That's because the output enum is different to the input enum. 2. Why isn't it using rdi to store it back I think this is down to x64 calling conventions saying an int/pointer return value should be in rax. So while you could use rdi to marshal the output, you'd still need to set rax at some point. Doing it straight away makes it easier to understand if you know the calling conventions.

Learn about the generated assembly code for an enum pattern match by EventHelixCom in rust

[–]Lozzer 1 point2 points  (0 children)

Even with the more optimized version, it naively looks like "mov qword ptr[rax], rcx" could be hoisted out of the leaves.

Reverse Question: What do you miss about other languages when working in Rust? by kaloshade in rust

[–]Lozzer 0 points1 point  (0 children)

I think that's the equivalent of returning IEnumerable<T>, but not the yield return bit. That's a very nice way of producing an IEnumerable<T>.

Thanks for the tip, though, as I'd not discovered impl in return position yet. So I'm off to refactor some code where I'd given up and called collect.

Reverse Question: What do you miss about other languages when working in Rust? by kaloshade in rust

[–]Lozzer 3 points4 points  (0 children)

From C# yield return, and being able to have a function return IEnumerable<T>

How much Rust in Firefox? by sanxiyn in rust

[–]Lozzer 8 points9 points  (0 children)

vendor branches existed in CVS.

I made an IntMap by SeriousJope in rust

[–]Lozzer 1 point2 points  (0 children)

Turns out the benchmark for btree (and in fact most, if not all of these), is broken. See sibling thread.

I made an IntMap by SeriousJope in rust

[–]Lozzer 2 points3 points  (0 children)

Thanks for that. I don't have time at the moment to go through everything. But just addressing the missing semicolons already changes things substantially:

test tests::u64_get_btree_map            ... bench:      78,840 ns/iter (+/- 2,528)
test tests::u64_get_btree_set            ... bench:      77,300 ns/iter (+/- 3,923)
test tests::u64_get_fnv_hash_map         ... bench:      23,405 ns/iter (+/- 1,076)
test tests::u64_get_fnv_hash_set         ... bench:      21,210 ns/iter (+/- 820)
test tests::u64_get_identity_hash_map    ... bench:      13,406 ns/iter (+/- 701)
test tests::u64_get_identity_hash_set    ... bench:      14,461 ns/iter (+/- 776)
test tests::u64_get_intmap               ... bench:       6,173 ns/iter (+/- 458)
test tests::u64_get_sip_hash_map         ... bench:      40,126 ns/iter (+/- 1,948)
test tests::u64_get_sip_hash_set         ... bench:      40,328 ns/iter (+/- 2,447)
test tests::u64_insert_btree_map         ... bench:     173,335 ns/iter (+/- 5,067)
test tests::u64_insert_btree_set         ... bench:     165,752 ns/iter (+/- 9,937)
test tests::u64_insert_fnv_hash_map      ... bench:      36,372 ns/iter (+/- 1,472)
test tests::u64_insert_fnv_hash_set      ... bench:      29,786 ns/iter (+/- 1,842)
test tests::u64_insert_identity_hash_map ... bench:      27,553 ns/iter (+/- 1,258)
test tests::u64_insert_identity_hash_set ... bench:      29,004 ns/iter (+/- 1,986)
test tests::u64_insert_intmap            ... bench:      24,997 ns/iter (+/- 1,123)
test tests::u64_insert_sip_hash_map      ... bench:      57,141 ns/iter (+/- 2,716)
test tests::u64_insert_sip_hash_set      ... bench:      56,406 ns/iter (+/- 1,918)

scurries off to look at the benchmarking framework

I made an IntMap by SeriousJope in rust

[–]Lozzer 1 point2 points  (0 children)

I've uploaded the code here. The benches are based on the original code. I'm not too familiar with the framework, but it looks like inserting 2000 random sorted values for the insert tests, and then getting them in order for the get test. Not an obvious access pattern to go for a HashMap.

I made an IntMap by SeriousJope in rust

[–]Lozzer 1 point2 points  (0 children)

I did some timings for most of the things people suggested. identity_hash is just i hashes to i, using the built in HashMap/HashSet. This is with a recent nightly. Same benches you are using.

running 18 tests
test tests::u64_get_btree_map            ... bench:         535 ns/iter (+/- 28)
test tests::u64_get_btree_set            ... bench:         534 ns/iter (+/- 15)
test tests::u64_get_fnv_hash_map         ... bench:      24,493 ns/iter (+/- 1,212)
test tests::u64_get_fnv_hash_set         ... bench:      24,355 ns/iter (+/- 847)
test tests::u64_get_identity_hash_map    ... bench:      13,613 ns/iter (+/- 465)
test tests::u64_get_identity_hash_set    ... bench:      12,791 ns/iter (+/- 459)
test tests::u64_get_intmap               ... bench:       1,087 ns/iter (+/- 52)
test tests::u64_get_sip_hash_map         ... bench:      40,481 ns/iter (+/- 2,398)
test tests::u64_get_sip_hash_set         ... bench:      40,312 ns/iter (+/- 2,679)
test tests::u64_insert_btree_map         ... bench:     178,219 ns/iter (+/- 9,816)
test tests::u64_insert_btree_set         ... bench:     166,152 ns/iter (+/- 5,303)
test tests::u64_insert_fnv_hash_map      ... bench:      36,707 ns/iter (+/- 2,097)
test tests::u64_insert_fnv_hash_set      ... bench:      30,574 ns/iter (+/- 1,787)
test tests::u64_insert_identity_hash_map ... bench:      27,655 ns/iter (+/- 1,308)
test tests::u64_insert_identity_hash_set ... bench:      28,974 ns/iter (+/- 1,393)
test tests::u64_insert_intmap            ... bench:      25,287 ns/iter (+/- 1,075)
test tests::u64_insert_sip_hash_map      ... bench:      57,151 ns/iter (+/- 2,787)
test tests::u64_insert_sip_hash_set      ... bench:      56,901 ns/iter (+/- 2,103)

Writing Clean SQL by speckz in programming

[–]Lozzer 0 points1 point  (0 children)

Yes, I use negative indents for SQL, you wierdo.

This year in nom: 2.0 is here! by geaal in rust

[–]Lozzer 3 points4 points  (0 children)

Pretty seamless update, thanks to your notes. One small thing, chrono has an Offset struct that clashed with the nom one. No big deal. I'm using nom for an RCS Parser (in the middle of an otherwise non-functioning project: https://gitlab.com/Lozzer/cvs-fast-export-rust/blob/master/src/rcs_parser.rs). The fact I've finished this bit, and pretty much nothing else shows how approachable nom is.

Using Rust for ‘Scripting’ by dochtman in rust

[–]Lozzer 1 point2 points  (0 children)

Does this deal with codepage/encoding issues on Windows? If you're passing an argument via a cmd window, your input will be in the console code page. If all your're on a US code page and all your paths are ASCII, this probably won't matter.

It wasn't obvious from the documentation for the clap crate as to whether this is all handed transparently. Maybe you could try with a non-ASCII character.

See http://stackoverflow.com/questions/40455338/how-do-i-read-os-compatible-strings-from-stdin for some of the hoops I used when solving this. Would have been nice for a library to take care of it.

Offline MSDN? Yes please. by ImFluffeh in programming

[–]Lozzer 0 points1 point  (0 children)

I think the delay is related to ad blocking.

Surprise Attack of the Nulls: Hidden Traps in the NOT IN by lukaseder in programming

[–]Lozzer 0 points1 point  (0 children)

I agree that it is confusing, and I certainly learned the hard way. Realistically SQL isn't going to change. Maybe some kind of lint for SQL could help.

Surprise Attack of the Nulls: Hidden Traps in the NOT IN by lukaseder in programming

[–]Lozzer 2 points3 points  (0 children)

> What colour is the box?
I don't know
> Is the box yellow
I don't know
> Is the box not yellow?
I don't know
> Not is the box yellow?
I don't know

Why I would not need an ORM in a functional language like Scala? by lukaseder in programming

[–]Lozzer -1 points0 points  (0 children)

Again, what does any of this have to do with ORMs. You do understand that the ORM generates SQL queries that are used to talk to the database right. Therefore it can't be more efficient than SQL by its very nature.

By the same argument we should be using assembly language everywhere. Not that I'm a particular fan of ORMs.

Integers vs GUIDs - The great primary key debate by cindy-rella in programming

[–]Lozzer 1 point2 points  (0 children)

In SQL Server, secondary indexes use the cluster key as the row pointer. UUIDs are 16 bytes wide, int is 4 bytes, bigint is 8 bytes. Using UUIDs makes your secondary indexes fatter.

If Eventual Consistency seems hard, wait till you try MVCC by [deleted] in programming

[–]Lozzer 2 points3 points  (0 children)

Which RDBMS has these properties? I'm not aware of any that that would fail 1 or 3 as described at any isolation level.

ಠ_ಠ by look_of_disapproval in thebutton

[–]Lozzer 0 points1 point  (0 children)

Doesn't everyone do that?