C
C#

help

Is Array.Copy decent for copying sections of memory?

TThinker9/28/2022
I'm making a thing which relies pretty heavily on copying (not very large) sections of memory inside an array to other sections of the array. Is Array.Copy decent for this or is there some other lower-level alternative that is more performant/efficient?
UUUnknown User9/28/2022
Message Not Public
Sign In & Join Server To View
TThinker9/28/2022
Well I have to rearrange stuff inside the array, but I guess I could use spans as auxiliary storage. To clarify, all the copy operations are from/to the same array.
SSWR9/28/2022
Array.Copy will be your best bet for copying beyond multithreading (which is not even guaranteed to be faster)
TThinker9/28/2022
Fair Last time I checked I think it does as many low-level optimizations as possible
SSWR9/28/2022
I'd say, follow the old saying : don't optimize until it's absolutely necessary
TThinker9/28/2022
True I'm writing a runtime for my own language, so some semblance of performance would be nice, although it's really not important that it's very efficient.
SSWR9/28/2022
Finally, it really depends on what problem you're trying to solve. An array may not even be the best data structure.
TThinker9/28/2022
hmm, I've considered using linked lists for what I'm doing, but I think I've settled on copying elements inside an array likely being the most efficient.
SSWR9/28/2022
If you're trying to have copied data exist in multiple parts of an array, and copies and can do to and from, you may get better performance with a graph data structure Rather than copying an array, you just connect nodes with a new edge. Hard to say for sure without context though
TThinker9/28/2022
true I'll go with this for, can always optimize it later

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
Relationship between Microsoft.AspNetCore.Identity.EntityFrameworkCore and AADHey guys, I read a bunch of Azure Active Directory documents and see that they recommend us not to sMSIX URI is inaccessible in AppinstallerHello, I have an Appinstaller and MSIX hosted in a public Google Cloud Storage bucket, meaning theyI'm having problems with a range of numbers and random generator (im new)I have an array of number (1-50, scaled), where one will be selected randomly and then every number EFCore Updating an item after mapping with AutomapperHey I am using Ef core to store some data in sqlite. I need to translate it to another object to shoIs it possible to allow an installer to downgrade dll's while not overwriting other app files?When creating an installer. (using Wix) Is there a way to have better control over the reinstall proIs there any way to simplify this, or a design pattern I should be following?```cs public event EventHandler<FizzbuzzDetermineNumberRequest>? DetermineNumberRequestHandlers; How to get service that not registed with interfaceHelpAssigning all StackPanel child element marginI am trying to set the margin for all elements in stackpanel from resor. Can you point out why it's Generics and type inference```cs public TDest MapTo<TSource, TDest>(TSource src) { var res = _mapper.Map<TSourcCrash of the background worker because of the SQL connectionI have a background worker running on some machine, which getting random crashes because of the SQL Minimum need data to create an EntityMy entity: ```cs public class Book : BaseEntity { public string Name { get; set; } MediatR commands and DTOs [Answered]Currently, I am passing DTOs to my controllers, I am using MediatR and it supports commands. I use tHow can I send int value from 1 program, to another via internet?```fix Hello. Is there any easy way to connect 2 programs to each other over the internet? I mean,InterfaceHi, i've this interface but there is only 1 class which doesn't need any parameter in `getAll(long iTroubleshooting Visual studio .net 6, debuggerHi, Ran in to a so strange bug/problem this week. I'm working in a multi tier solution with several✅ Amazon Review Panic!!!Hello, I am a Freshman in college who was recently selected for a technical interview at Amazon. I aSearch for text and sort by most hits.I wrote a function like this, it looks for words in the database. I would like to make it sort by thValidation helpNeed help with some simple validationPrevent scrollbar from jumping down when viewing a list?Hi - I'm making a chat room in windows forms and have a listbox that displays all the messages recieWPF Border around transparent imageI'm trying to do a kind of "magic wand tool" selection that some image editors have, and I just can'