Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
What is the general difference between loadRef() and preloadRef(), for example?

As mentioned, I have used loadRef(), but I don't understand the difference between loadRef() and preloadRef() (https://docs.tact-lang.org/language/ref/cells#sliceloadref).

My question is: Can using preloadRef() cause a crash or result in reading wrong data from another memory space? And what is the difference between loadRef() and preloadRef()?

The question was import from: https://t.me/tondev_eng/24298

  
  
Posted one year ago
Votes Newest

Answers


In Tact, loadRef() and preloadRef() functions are used to retrieve data from a reference cell into a variable, without any promises or async involved.

However, they differ in their behavior when dealing with reference cells that contain slices.

loadRef() consumes the reference to the slice and returns its contents. This means that loadRef() can only be used once on a reference cell that contains a slice.

preloadRef() loads the contents of the slice in the background and returns a new reference to the slice. This allows preloadRef() to be used multiple times on a reference cell that contains a slice, without consuming the original reference.

Regarding your question, using preloadRef() should not cause a crash or result in reading wrong data from another memory space, as long as it is used appropriately. However, it is important to understand the difference between the two functions and use them accordingly to avoid unexpected behavior in your program.

In Tact, or the first question I asked, I used this to solve the problem.

let dataCell: Cell = msg.custom_payload!!;
let sc: Slice = dataCell.beginParse(); // set a new slice

self.value = sc.loadUint(256);
self.individual_content = sc.loadRef();
  
  
Posted one year ago
Edited one year ago
964 Views
1 Answer
one year ago
one year ago
Tags